Class TextChunker

java.lang.Object
io.agentscope.core.rag.reader.TextChunker

public final class TextChunker extends Object
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 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 chunk
      chunkSize - the target size for each chunk (interpreted based on strategy)
      strategy - the splitting strategy
      overlapSize - the number of characters/tokens to overlap between chunks
      Returns:
      a list of text chunks