WordReader
public class WordReader extends AbstractChunkingReader
io/agentscope/core/rag/reader/WordReader.java:68–552Word 读取器,把私有文档转化为可检索的知识。位于 io.agentscope.core.rag.reader 包,继承自 AbstractChunkingReader。核心成员包括 read、getSupportedFormats、isIncludeImage、isSeparateTable、getTableFormat、WordReader。
Word document reader that extracts text, tables, and images from Word files.
This reader supports comprehensive extraction of content from Word documents (.docx), including:
-
Text extraction from paragraphs
-
Table extraction with Markdown or JSON formatting
-
Image extraction with Base64 encoding
-
Configurable chunking strategies
Dependencies: Requires Apache POI (poi-ooxml) to be available on the classpath.
Example usage:
`WordReader reader = new WordReader(512, SplitStrategy.PARAGRAPH, 50,
true, false, TableFormat.MARKDOWN);
ReaderInput input = ReaderInput.fromString("path/to/document.docx");
List<Document> documents = reader.read(input).block();
`
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public WordReader(int chunkSize, SplitStrategy splitStrategy, int overlapSize, boolean includeImage, boolean separateTable, TableFormat tableFormat) | 初始化 `WordReader` 实例。 Creates a new WordReader with full configuration. |
public WordReader() | 创建新的WordReader 使用默认设置。 Creates a new WordReader 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. |
public boolean isIncludeImage() | 判断是否 `isIncludeImage`。 Checks if image extraction is enabled. |
public boolean isSeparateTable() | 判断是否 `isSeparateTable`。 Checks if tables are separated into individual chunks. |
public TableFormat getTableFormat() | 获取 `getTableFormat`。 Gets the table format. |
构造器详情Constructor Detail
WordReader
public WordReader(int chunkSize, SplitStrategy splitStrategy, int overlapSize, boolean includeImage, boolean separateTable, TableFormat tableFormat)
初始化 WordReader 实例。
Creates a new WordReader with full configuration.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
chunkSize | int | 目标大小用于每个分块。the target size for each chunk |
splitStrategy | SplitStrategy | 已拆分 Strategy(类型 `SplitStrategy`)。the strategy for splitting text |
overlapSize | int | overlap 大小(类型 `int`)。the number of characters to overlap between chunks |
includeImage | boolean | include 图像(类型 `boolean`)。whether to extract and include images from the document |
separateTable | boolean | separate Table(类型 `boolean`)。whether to treat tables as separate chunks |
tableFormat | TableFormat | table 格式(类型 `TableFormat`)。the format for extracted tables (MARKDOWN or JSON) |
IllegalArgumentException可能抛出 `IllegalArgumentException`。if parameters are invalid
io/agentscope/core/rag/reader/WordReader.java:85–99WordReader
public WordReader()
创建新的WordReader 使用默认设置。
Creates a new WordReader with default settings.
io/agentscope/core/rag/reader/WordReader.java:114–116方法详情Method Detail
read
public Mono<List<Document>> read(ReaderInput input)
设置读取。
Performs the read operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
input | ReaderInput | 输入消息(类型 `ReaderInput`)。The input. |
Mono<List<Document>>io/agentscope/core/rag/reader/WordReader.java:118–185getSupportedFormats
public List<String> getSupportedFormats()
获取 getSupportedFormats。
Returns the supported formats.
List<String>io/agentscope/core/rag/reader/WordReader.java:187–190isIncludeImage
public boolean isIncludeImage()
判断是否 isIncludeImage。
Checks if image extraction is enabled.
booleanio/agentscope/core/rag/reader/WordReader.java:531–533isSeparateTable
public boolean isSeparateTable()
判断是否 isSeparateTable。
Checks if tables are separated into individual chunks.
booleanio/agentscope/core/rag/reader/WordReader.java:540–542getTableFormat
public TableFormat getTableFormat()
获取 getTableFormat。
Gets the table format.
TableFormatio/agentscope/core/rag/reader/WordReader.java:549–551