Package io.agentscope.core.rag.reader
Class TextChunker
java.lang.Object
io.agentscope.core.rag.reader.TextChunker
Utility class for chunking text into smaller pieces.
This class provides methods to split text according to different strategies, with support for overlap between chunks to preserve context.
-
Method Summary
Modifier and TypeMethodDescriptionchunkText(String text, int chunkSize, SplitStrategy strategy, int overlapSize) Chunks text according to the specified strategy.
-
Method Details
-
chunkText
public static List<String> chunkText(String text, int chunkSize, SplitStrategy strategy, int overlapSize) Chunks text according to the specified strategy.- Parameters:
text- the text to chunkchunkSize- the target size for each chunk (interpreted based on strategy)strategy- the splitting strategyoverlapSize- the number of characters/tokens to overlap between chunks- Returns:
- a list of text chunks
-