mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-03 22:30:31 +08:00
87 lines
2.0 KiB
Go
87 lines
2.0 KiB
Go
//go:build !cgo
|
|
|
|
package parser
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
)
|
|
|
|
// ErrOfficeCGORequired is returned by ParseWithResult on every
|
|
// office-parser family (DOC / DOCX / PPT / PPTX)
|
|
// when the build is not CGO-enabled. The CGO build's
|
|
// implementation captures the office_oxide PlainText / ToMarkdown
|
|
// output; this stub mirrors that surface so the package compiles
|
|
// and existing tests pass. The error is surfaced at parse time
|
|
// rather than at construction time, matching the NewPDFParser
|
|
// shape used by the rest of the package.
|
|
var ErrOfficeCGORequired = errors.New("parser: office family requires CGO (office_oxide)")
|
|
|
|
func (p *DOCXParser) ParseWithResult(filename string, _ []byte) ParseResult {
|
|
return ParseResult{
|
|
File: map[string]any{"name": filename},
|
|
Err: fmt.Errorf("%w: docx", ErrOfficeCGORequired),
|
|
}
|
|
}
|
|
|
|
func (p *DOCParser) ParseWithResult(filename string, _ []byte) ParseResult {
|
|
return ParseResult{
|
|
File: map[string]any{"name": filename},
|
|
Err: fmt.Errorf("%w: doc", ErrOfficeCGORequired),
|
|
}
|
|
}
|
|
|
|
func (p *PPTParser) ParseWithResult(filename string, _ []byte) ParseResult {
|
|
return ParseResult{
|
|
File: map[string]any{"name": filename},
|
|
Err: fmt.Errorf("%w: ppt", ErrOfficeCGORequired),
|
|
}
|
|
}
|
|
|
|
func (p *PPTXParser) ParseWithResult(filename string, _ []byte) ParseResult {
|
|
return ParseResult{
|
|
File: map[string]any{"name": filename},
|
|
Err: fmt.Errorf("%w: pptx", ErrOfficeCGORequired),
|
|
}
|
|
}
|
|
|
|
type DOCParser struct{}
|
|
|
|
func NewDOCParser() *DOCParser {
|
|
return &DOCParser{}
|
|
}
|
|
|
|
func (p *DOCParser) String() string {
|
|
return "DOCParser(no-cgo)"
|
|
}
|
|
|
|
type DOCXParser struct{}
|
|
|
|
func NewDOCXParser() *DOCXParser {
|
|
return &DOCXParser{}
|
|
}
|
|
|
|
func (p *DOCXParser) String() string {
|
|
return "DOCXParser(no-cgo)"
|
|
}
|
|
|
|
type PPTParser struct{}
|
|
|
|
func NewPPTParser() *PPTParser {
|
|
return &PPTParser{}
|
|
}
|
|
|
|
func (p *PPTParser) String() string {
|
|
return "PPTParser(no-cgo)"
|
|
}
|
|
|
|
type PPTXParser struct{}
|
|
|
|
func NewPPTXParser() *PPTXParser {
|
|
return &PPTXParser{}
|
|
}
|
|
|
|
func (p *PPTXParser) String() string {
|
|
return "PPTXParser(no-cgo)"
|
|
}
|