Class AbstractChunkingReader

java.lang.Object
io.agentscope.core.rag.reader.AbstractChunkingReader
All Implemented Interfaces:
Reader
Direct Known Subclasses:
ExternalApiReader, PDFReader, TextReader, TikaReader, WordReader

public abstract class AbstractChunkingReader extends Object implements Reader
Abstract base class for readers that support text chunking.

This class provides common functionality for document readers that split content into chunks based on a chunking strategy. It handles parameter validation and provides shared access to chunk size, split strategy, and overlap size settings.

Subclasses should implement the Reader interface to provide specific reading logic for different file formats.

  • Field Details

    • chunkSize

      protected final int chunkSize
    • splitStrategy

      protected final SplitStrategy splitStrategy
    • overlapSize

      protected final int overlapSize
  • Constructor Details

    • AbstractChunkingReader

      protected AbstractChunkingReader(int chunkSize, SplitStrategy splitStrategy, int overlapSize)
      Creates a new AbstractChunkingReader with the specified configuration.
      Parameters:
      chunkSize - the target size for each chunk (interpreted based on strategy)
      splitStrategy - the strategy for splitting text
      overlapSize - the number of characters/tokens to overlap between chunks
      Throws:
      IllegalArgumentException - if parameters are invalid
  • Method Details

    • validateChunkingParameters

      protected static void validateChunkingParameters(int chunkSize, SplitStrategy splitStrategy, int overlapSize)
      Validates chunking parameters.
      Parameters:
      chunkSize - the chunk size to validate
      splitStrategy - the split strategy to validate
      overlapSize - the overlap size to validate
      Throws:
      IllegalArgumentException - if any parameter is invalid
    • getChunkSize

      public int getChunkSize()
      Gets the chunk size.
      Returns:
      the chunk size
    • getSplitStrategy

      public SplitStrategy getSplitStrategy()
      Gets the split strategy.
      Returns:
      the split strategy
    • getOverlapSize

      public int getOverlapSize()
      Gets the overlap size.
      Returns:
      the overlap size