Skip to content

TextChunker

Namespace AgentPrism · Assembly AgentPrism.Core.dll

Splits text into fixed-length chunks with overlap.

public static class TextChunker

objectTextChunker

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

It is intentionally simple. Intelligent chunking based on headings or semantics is outside the library boundary. Consumers can send their own chunks directly.

Splits text into chunks with overlap.

public static IReadOnlyList<string> Split(string text, int chunkSize, int chunkOverlap)

text string

The text to split.

chunkSize int

The chunk length in characters. It must be positive.

chunkOverlap int

The overlap length between consecutive chunks, in characters. It must be less than chunkSize; otherwise, the method cannot progress.

IReadOnlyList<string>

The chunk text in order, or an empty list for empty text.

ArgumentOutOfRangeException

chunkSize is zero or negative, or chunkOverlap is negative or greater than or equal to chunkSize.