Package io.agentscope.core.rag.reader
Class AbstractChunkingReader
java.lang.Object
io.agentscope.core.rag.reader.AbstractChunkingReader
- All Implemented Interfaces:
Reader
- Direct Known Subclasses:
ExternalApiReader,PDFReader,TextReader,TikaReader,WordReader
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 Summary
FieldsModifier and TypeFieldDescriptionprotected final intprotected final intprotected final SplitStrategy -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractChunkingReader(int chunkSize, SplitStrategy splitStrategy, int overlapSize) Creates a new AbstractChunkingReader with the specified configuration. -
Method Summary
Modifier and TypeMethodDescriptionintGets the chunk size.intGets the overlap size.Gets the split strategy.protected static voidvalidateChunkingParameters(int chunkSize, SplitStrategy splitStrategy, int overlapSize) Validates chunking parameters.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.agentscope.core.rag.reader.Reader
getSupportedFormats, read
-
Field Details
-
chunkSize
protected final int chunkSize -
splitStrategy
-
overlapSize
protected final int overlapSize
-
-
Constructor Details
-
AbstractChunkingReader
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 textoverlapSize- 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 validatesplitStrategy- the split strategy to validateoverlapSize- 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
Gets the split strategy.- Returns:
- the split strategy
-
getOverlapSize
public int getOverlapSize()Gets the overlap size.- Returns:
- the overlap size
-