TextReader
public class TextReader extends AbstractChunkingReader
源码Source
io/agentscope/core/rag/reader/TextReader.java:41–108文本读取器,把私有文档转化为可检索的知识。位于 io.agentscope.core.rag.reader 包,继承自 AbstractChunkingReader。核心成员包括 read、getSupportedFormats、TextReader。
Text reader implementation that reads and chunks text documents.
This reader supports various text formats and splitting strategies. It can read text from strings or files and split them into chunks according to the specified strategy.
Example usage:
`TextReader reader = new TextReader(512, SplitStrategy.PARAGRAPH, 50);
ReaderInput input = ReaderInput.fromString("Long text content...");
List<Document> documents = reader.read(input).block();
`
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public TextReader(int chunkSize, SplitStrategy splitStrategy, int overlapSize) | 初始化 `TextReader` 实例。 Creates a new TextReader with the specified configuration. |
public TextReader() | 创建新的TextReader 使用默认设置。 Creates a new TextReader with default settings. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public Mono<List<Document>> read(ReaderInput input) | 设置读取。 Performs the read operation. |
public List<String> getSupportedFormats() | 获取 `getSupportedFormats`。 Returns the supported formats. |
构造器详情Constructor Detail
TextReader
public TextReader(int chunkSize, SplitStrategy splitStrategy, int overlapSize)
初始化 TextReader 实例。
Creates a new TextReader with the specified configuration.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
chunkSize | int | 分块大小(类型 `int`)。the target size for each chunk (interpreted based on strategy) |
splitStrategy | SplitStrategy | 已拆分 Strategy(类型 `SplitStrategy`)。the strategy for splitting text |
overlapSize | int | overlap 大小(类型 `int`)。the number of characters/tokens to overlap between chunks |
IllegalArgumentException可能抛出 `IllegalArgumentException`。if parameters are invalid
源码Source
io/agentscope/core/rag/reader/TextReader.java:51–53TextReader
public TextReader()
创建新的TextReader 使用默认设置。
Creates a new TextReader with default settings.
源码Source
io/agentscope/core/rag/reader/TextReader.java:60–62方法详情Method Detail
read
public Mono<List<Document>> read(ReaderInput input)
设置读取。
Performs the read operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
input | ReaderInput | 输入消息(类型 `ReaderInput`)。The input. |
Mono<List<Document>>返回Mono>。Returns mono.
源码Source
io/agentscope/core/rag/reader/TextReader.java:64–83getSupportedFormats
public List<String> getSupportedFormats()
获取 getSupportedFormats。
Returns the supported formats.
List<String>返回列出。Returns list.
源码Source
io/agentscope/core/rag/reader/TextReader.java:85–88