Documentation
¶
Overview ¶
Package fileparser 提供从各种文件格式中提取结构化文档的能力。 所有解析器输出统一的 document.Document 结构,供上层 RAG/检索引擎消费。
Index ¶
- type CSVParser
- type HTMLParser
- type JSONParser
- type MarkdownParser
- type PDFParser
- type Parser
- type ParserManager
- func (pm *ParserManager) GetParserByExtension(ext string) Parser
- func (pm *ParserManager) GetParserBySource(source string) Parser
- func (pm *ParserManager) ParseByReader(reader io.Reader, source string) (*document.Document, error)
- func (pm *ParserManager) ParseFromPath(path string) (*document.Document, error)
- func (pm *ParserManager) SupportedExtensions() []string
- type TextParser
- type WordParser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CSVParser ¶
type CSVParser struct{}
CSVParser CSV 文件解析器
func NewCSVParser ¶
func NewCSVParser() *CSVParser
type HTMLParser ¶
type HTMLParser struct{}
HTMLParser HTML 文档解析器(基于简单的正则 + 有限的 XML 解析)
func NewHTMLParser ¶
func NewHTMLParser() *HTMLParser
func (*HTMLParser) Name ¶
func (p *HTMLParser) Name() string
type JSONParser ¶
type JSONParser struct{}
JSONParser JSON 文件解析器
func NewJSONParser ¶
func NewJSONParser() *JSONParser
func (*JSONParser) Name ¶
func (p *JSONParser) Name() string
type MarkdownParser ¶
type MarkdownParser struct{}
MarkdownParser Markdown 文档解析器
func NewMarkdownParser ¶
func NewMarkdownParser() *MarkdownParser
func (*MarkdownParser) Name ¶
func (p *MarkdownParser) Name() string
type PDFParser ¶
type PDFParser struct{}
PDFParser PDF 文件解析器 使用 ledongthuc/pdf 库按页提取文本
func NewPDFParser ¶
func NewPDFParser() *PDFParser
type Parser ¶
type Parser interface {
// Parse 从 reader 解析内容为结构化文档,source 用于错误提示与标题
Parse(reader io.Reader, source string) (*document.Document, error)
// Name 返回解析器名称(用于调试)
Name() string
}
Parser 文件解析器接口
type ParserManager ¶
type ParserManager struct {
// contains filtered or unexported fields
}
ParserManager 根据文件扩展名选择合适的解析器
func (*ParserManager) GetParserByExtension ¶
func (pm *ParserManager) GetParserByExtension(ext string) Parser
GetParserByExtension 根据扩展名返回对应的解析器
func (*ParserManager) GetParserBySource ¶
func (pm *ParserManager) GetParserBySource(source string) Parser
GetParserBySource 根据文件路径选择解析器
func (*ParserManager) ParseByReader ¶
ParseByReader 使用指定扩展名的解析器来解析 reader
func (*ParserManager) ParseFromPath ¶
func (pm *ParserManager) ParseFromPath(path string) (*document.Document, error)
ParseFromPath 打开文件并解析
func (*ParserManager) SupportedExtensions ¶
func (pm *ParserManager) SupportedExtensions() []string
SupportedExtensions 返回当前管理器支持的所有扩展名
type TextParser ¶
type TextParser struct{}
TextParser 纯文本文件解析器
func NewTextParser ¶
func NewTextParser() *TextParser
func (*TextParser) Name ¶
func (p *TextParser) Name() string
type WordParser ¶
type WordParser struct{}
WordParser DOCX 文件解析器 DOCX 文件本质是 ZIP 包,内有 word/document.xml 等资源
func NewWordParser ¶
func NewWordParser() *WordParser
func (*WordParser) Name ¶
func (p *WordParser) Name() string
Click to show internal directories.
Click to hide internal directories.