mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-26 10:23:28 +08:00
## Summary Adds construction-time parameter validation to the ingestion `ParserComponent` (mirroring the applicable subset of Python `ParserParam.check()`), fixes a family-mapping mismatch that silently skipped `output_format` validation and setup configuration for image/audio files, and aligns the no-CGO parser stubs with the CGO variants by threading `context.Context` through `ParseWithResult`.
37 lines
937 B
Go
37 lines
937 B
Go
//go:build !cgo
|
|
|
|
package parser
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
)
|
|
|
|
func (p *PDFParser) ParseWithResult(ctx context.Context, filename string, data []byte) ParseResult {
|
|
if err := p.validateParseMethod(); err != nil {
|
|
return ParseResult{Err: err}
|
|
}
|
|
switch normalizePDFParseMethod(p.ParseMethod) {
|
|
case "plain_text":
|
|
return parsePDFWithPlainText(filename, data, p)
|
|
case "mineru":
|
|
return parsePDFWithMinerU(ctx, filename, data, p)
|
|
case "paddleocr":
|
|
return parsePDFWithPaddleOCR(ctx, filename, data, p)
|
|
case "docling":
|
|
return parsePDFWithDocling(ctx, filename, data, p)
|
|
case "opendataloader":
|
|
return parsePDFWithOpenDataLoader(ctx, filename, data, p)
|
|
case "somark":
|
|
return parsePDFWithSoMark(filename, data, p)
|
|
case "tcadp":
|
|
return parsePDFWithTCADP(filename, data, p)
|
|
}
|
|
if len(data) == 0 {
|
|
return emptyPDFResult(filename)
|
|
}
|
|
return ParseResult{
|
|
Err: fmt.Errorf("%w: %s", ErrPDFEngineUnavailable, filename),
|
|
}
|
|
}
|