PDFReader
public class PDFReader extends AbstractChunkingReader
io/agentscope/core/rag/reader/PDFReader.java:53–190PDF 读取器,把私有文档转化为可检索的知识。位于 io.agentscope.core.rag.reader 包,继承自 AbstractChunkingReader。核心成员包括 read、getSupportedFormats、isExtractImages、PDFReader。
PDF reader implementation that reads and extracts text from PDF files.
This reader extracts text content from PDF files and chunks it according to the specified strategy. It supports various text splitting strategies similar to TextReader.
Note: This is a basic implementation that reads PDF files as text. For full PDF parsing with proper text extraction, additional dependencies (e.g., Apache PDFBox) would be required. This implementation provides a foundation that can be extended.
Example usage:
`PDFReader reader = new PDFReader(512, SplitStrategy.PARAGRAPH, 50);
ReaderInput input = ReaderInput.fromString("path/to/document.pdf");
List<Document> documents = reader.read(input).block();
`
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public PDFReader(int chunkSize, SplitStrategy splitStrategy, int overlapSize) | 初始化 `PDFReader` 实例。 Creates a new PDFReader with the specified configuration. |
public PDFReader(int chunkSize, SplitStrategy splitStrategy, int overlapSize, boolean extractImages) | 初始化 `PDFReader` 实例。 Creates a new PDFReader with the specified configuration. |
public PDFReader() | 创建新的PDFReader 使用默认设置。 Creates a new PDFReader 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 isExtractImages() | 判断是否 `isExtractImages`。 Checks if image extraction is enabled. |
构造器详情Constructor Detail
PDFReader
public PDFReader(int chunkSize, SplitStrategy splitStrategy, int overlapSize)
初始化 PDFReader 实例。
Creates a new PDFReader with the specified 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 |
IllegalArgumentException可能抛出 `IllegalArgumentException`。if parameters are invalid
io/agentscope/core/rag/reader/PDFReader.java:65–67PDFReader
public PDFReader(int chunkSize, SplitStrategy splitStrategy, int overlapSize, boolean extractImages)
初始化 PDFReader 实例。
Creates a new PDFReader with the specified 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 |
extractImages | boolean | extract Images(类型 `boolean`)。true to extract images from PDF (placeholder for future implementation) |
IllegalArgumentException可能抛出 `IllegalArgumentException`。if parameters are invalid
io/agentscope/core/rag/reader/PDFReader.java:79–83PDFReader
public PDFReader()
创建新的PDFReader 使用默认设置。
Creates a new PDFReader with default settings.
io/agentscope/core/rag/reader/PDFReader.java:90–92方法详情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/PDFReader.java:94–114getSupportedFormats
public List<String> getSupportedFormats()
获取 getSupportedFormats。
Returns the supported formats.
List<String>io/agentscope/core/rag/reader/PDFReader.java:116–119isExtractImages
public boolean isExtractImages()
判断是否 isExtractImages。
Checks if image extraction is enabled.
booleanio/agentscope/core/rag/reader/PDFReader.java:187–189