Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Remove noocr/SkipOCR dead code path and text-layer-only parity test (#18443)

Jackb78b559ac5b3
diff --git a/internal/common/environments.go b/internal/common/environments.go
index 7260cbb69f..20b3120831 100644
--- a/internal/common/environments.go
+++ b/internal/common/environments.go
@@ -134,7 +134,6 @@ const (
EnvBatchSingle = "BATCH_SINGLE"
EnvBatchCount = "BATCH_COUNT"
EnvBatchLogLevel = "BATCH_LOG_LEVEL"
- EnvBatchSkipOCR = "BATCH_SKIP_OCR"
EnvBatchCompareOnly = "BATCH_COMPARE_ONLY"
EnvBatchCompareFilter = "BATCH_COMPARE_FILTER"
EnvBatchCompareCSV = "BATCH_COMPARE_CSV"
diff --git a/internal/deepdoc/parser/pdf/batch_smoke_test.go b/internal/deepdoc/parser/pdf/batch_smoke_test.go
index e25e6f99d5..e1fe712345 100644
--- a/internal/deepdoc/parser/pdf/batch_smoke_test.go
+++ b/internal/deepdoc/parser/pdf/batch_smoke_test.go
@@ -35,7 +35,6 @@ import (
//
// DeepDoc is mandatory (DLA+TSR are inseparable from the pipeline).
//
-// BATCH_SKIP_OCR=1 skip image OCR (DLA+TSR kept)
// BATCH_COUNT=N limit to first N PDFs (by file size, smallest first)
// BATCH_SINGLE=name process exactly one PDF (full filename)
//
@@ -62,9 +61,8 @@ func TestBatchResults(t *testing.T) {
}
deepDoc := pdf.DocAnalyzer(ddClient)
- variant := variantFromEnv()
- t.Logf("DeepDoc available — DLA+TSR%s enabled (%d PDFs)",
- map[bool]string{true: ", image OCR skipped", false: ", OCR enabled"}[variant == "noocr"], len(pdfs))
+ variant := "ocr"
+ t.Logf("DeepDoc available — DLA+TSR+OCR enabled (%d PDFs)", len(pdfs))
dirs := mkOutputDirs(variant)
@@ -84,13 +82,6 @@ func setupLogger() {
slog.SetDefault(slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: level})))
}
-func variantFromEnv() string {
- if common.GetEnv(common.EnvBatchSkipOCR) == "1" {
- return "noocr"
- }
- return "ocr"
-}
-
type outputDirs struct {
text, tables, dla, tsr string
}
@@ -182,7 +173,6 @@ func processPDFs(t *testing.T, pdfDir string, pdfs []string, deepDoc pdf.DocAnal
t.Helper()
var results []tool.BatchResult
totalChars := 0
- skipOCR := common.GetEnv(common.EnvBatchSkipOCR) == "1"
for i, name := range pdfs {
label := fmt.Sprintf("[%d/%d] %s", i+1, len(pdfs), name)
@@ -197,7 +187,7 @@ func processPDFs(t *testing.T, pdfDir string, pdfs []string, deepDoc pdf.DocAnal
}
// ── parse ──
- res, err := parseOne(pdfDir, name, deepDoc, skipOCR)
+ res, err := parseOne(pdfDir, name, deepDoc)
if err != nil {
results = append(results, tool.BatchResult{File: name, Error: err.Error()})
t.Logf("%s — %v", label, err)
@@ -223,7 +213,7 @@ type parseOneResult struct {
result pdf.ParseResult
}
-func parseOne(pdfDir, name string, deepDoc pdf.DocAnalyzer, skipOCR bool) (*parseOneResult, error) {
+func parseOne(pdfDir, name string, deepDoc pdf.DocAnalyzer) (*parseOneResult, error) {
data, err := os.ReadFile(filepath.Join(pdfDir, name))
if err != nil {
return nil, fmt.Errorf("read: %w", err)
@@ -239,7 +229,6 @@ func parseOne(pdfDir, name string, deepDoc pdf.DocAnalyzer, skipOCR bool) (*pars
chars, _ := extractPageStats(eng)
cfg := pdf.DefaultParserConfig()
- cfg.SkipOCR = skipOCR
p := NewParser(cfg)
t0 := time.Now()
parsed, err := p.ParseRaw(context.Background(), eng, deepDoc)
diff --git a/internal/deepdoc/parser/pdf/compare_test.go b/internal/deepdoc/parser/pdf/compare_test.go
index a4fd628f91..1a15a728c0 100644
--- a/internal/deepdoc/parser/pdf/compare_test.go
+++ b/internal/deepdoc/parser/pdf/compare_test.go
@@ -14,8 +14,8 @@ import (
// TestBatchCompareWithPython compares Go output against Python reference
// across 4 dimensions (text, tables, DLA, TSR raw). It is read-only —
-// no generation, no CGO/DeepDoc dependency. Use BATCH_SKIP_OCR=1 to
-// compare the noocr variant; PY_OCR_SUFFIX to override the Python variant.
+// no generation, no CGO/DeepDoc dependency. Use PY_OCR_SUFFIX to override
+// the Python variant.
func TestBatchCompareWithPython(t *testing.T) {
level := slog.LevelInfo
if common.GetEnv(common.EnvBatchLogLevel) == "debug" {
@@ -27,9 +27,6 @@ func TestBatchCompareWithPython(t *testing.T) {
slog.SetDefault(slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: level})))
goVariant := "ocr"
- if common.GetEnv(common.EnvBatchSkipOCR) == "1" {
- goVariant = "noocr"
- }
pyVariant := common.GetEnv(common.EnvPYOCRSuffix)
if pyVariant == "" {
pyVariant = goVariant
diff --git a/internal/deepdoc/parser/pdf/parser.go b/internal/deepdoc/parser/pdf/parser.go
index c1434c6bc1..70a500bb1c 100644
--- a/internal/deepdoc/parser/pdf/parser.go
+++ b/internal/deepdoc/parser/pdf/parser.go
@@ -167,7 +167,7 @@ func (p *Parser) extractOutlines(engine pdf.PDFEngine) []pdf.Outline {
// artifacts are returned in pageResult for the global assembly phase.
//
// Zoom retry is per-page: if the default zoom produces no boxes and
-// conditions allow (Zoom < 9, !SkipOCR, render succeeded), the page is
+// conditions allow (Zoom < 9, render succeeded), the page is
// re-rendered at Config.Zoom × DlaScale and OCR/DLA are re-run. This
// replaces the old document-wide retryZoom pass and ensures only pages
// that actually need a higher zoom pay the memory cost.
@@ -223,7 +223,7 @@ func (p *Parser) processPage(ctx context.Context, engine pdf.PDFEngine, pg int,
// Per-page zoom retry: if no boxes were produced at the default zoom
// and conditions allow, re-render at a higher zoom and re-run OCR/DLA.
- if len(annotated) == 0 && p.Config.Zoom >= 1.0 && !p.Config.SkipOCR && renderErr == nil {
+ if len(annotated) == 0 && p.Config.Zoom >= 1.0 && renderErr == nil {
// Cap the retry zoom so a large Config.Zoom cannot drive the retry
// render to an unsafe DPI and spike memory on large pages.
const maxRetryZoom = 9.0
@@ -308,7 +308,7 @@ func (p *Parser) processPageBoxes(ctx context.Context, pageImg image.Image, char
var ocrBoxes []pdf.TextBox
ocrUsed := false
- if !p.Config.SkipOCR && renderErr == nil && pageImg != nil {
+ if renderErr == nil && pageImg != nil {
hasCleanChars := len(chars) > 0 && !isScanNoise && !util.IsGarbledPage(chars)
if hasCleanChars {
ocrBoxes = p.ocrMergeChars(ctx, pageImg, chars, docAnalyzer, pg)
diff --git a/internal/deepdoc/parser/pdf/parser_pipeline_integration_test.go b/internal/deepdoc/parser/pdf/parser_pipeline_integration_test.go
index 81a778a9e7..1ffca49fb0 100644
--- a/internal/deepdoc/parser/pdf/parser_pipeline_integration_test.go
+++ b/internal/deepdoc/parser/pdf/parser_pipeline_integration_test.go
@@ -648,7 +648,6 @@ func TestIntegration_TableRotation(t *testing.T) {
// pages (regions and characters are in different coordinate
// spaces post-rotation). Character extraction and rotation are
// verified via the lyt.CharsToBoxes path.
- cfg.SkipOCR = true
p := NewParser(cfg)
result, err := p.Parse(context.Background(), data, client)
if err != nil {
diff --git a/internal/deepdoc/parser/pdf/pipeline_parity_test.go b/internal/deepdoc/parser/pdf/pipeline_parity_test.go
deleted file mode 100644
index b9f7d3b983..0000000000
--- a/internal/deepdoc/parser/pdf/pipeline_parity_test.go
+++ /dev/null
@@ -1,269 +0,0 @@
-//go:build cgo && manual
-
-package pdf
-
-import (
- "os"
- "path/filepath"
- "sort"
- "strings"
- "testing"
-
- "ragflow/internal/common"
- lyt "ragflow/internal/deepdoc/parser/pdf/layout"
- "ragflow/internal/deepdoc/parser/pdf/tool"
- pdf "ragflow/internal/deepdoc/parser/pdf/type"
- util "ragflow/internal/deepdoc/parser/pdf/util"
-)
-
-// TestPipelineParity verifies Go pipeline logic equivalence with Python.
-// It loads Python pdfplumber chars (from charspy/), runs the Go pipeline
-// with Top-based sorting to match Python's ordering, and compares sections
-// against Python's output/py/noocr/text/ output.
-//
-// CharSim must be 100% — if not, Go pipeline logic differs from Python's.
-func TestPipelineParity(t *testing.T) {
- charspyDir := filepath.Join("testdata", "charspy")
- pyTextDir := filepath.Join("testdata", "output", "py", "noocr", "text")
-
- entries, err := os.ReadDir(charspyDir)
- if err != nil {
- t.Skipf("charspy/ not found: %v", err)
- }
-
- filter := common.GetEnv(common.EnvBatchParityFilter)
-
- total, passed := 0, 0
- for _, e := range entries {
- if e.IsDir() || !strings.HasSuffix(e.Name(), ".json") {
- continue
- }
- name := strings.TrimSuffix(e.Name(), ".json")
- if filter != "" && !strings.Contains(e.Name(), filter) {
- continue
- }
-
- // Load Python chars
- jsonPath := filepath.Join(charspyDir, e.Name())
- engine, err := tool.LoadPythonChars(jsonPath)
- if err != nil {
- t.Errorf("%s: tool.LoadPythonChars: %v", name, err)
- continue
- }
-
- // Run Go pipeline (SKIP_OCR — no DeepDoc)
- cfg := pdf.DefaultParserConfig()
- cfg.SortByTop = true
- mockAnalyzer := &MockDocAnalyzer{Healthy: true}
- p := NewParser(cfg)
- result, err := p.ParseRaw(t.Context(), engine, mockAnalyzer)
- if err != nil {
- t.Errorf("%s: Parse: %v", name, err)
- continue
- }
-
- // Read Python sections
- pyPath := filepath.Join(pyTextDir, name+".txt")
- pyData, err := os.ReadFile(pyPath)
- if err != nil {
- t.Logf("%s: no Python reference at %s — skip", name, pyPath)
- continue
- }
-
- // Build Go text
- var goText strings.Builder
- for _, s := range result.Sections {
- goText.WriteString(s.Text)
- goText.WriteByte('\n')
- }
-
- // Compare
- sim := tool.CharSimilarity(goText.String(), tool.StripMeta(string(pyData)))
- total++
- if sim >= 100.0 {
- passed++
- t.Logf("PASS %s: CharSim=%.1f%% boxes:%d->%d->%d->%d",
- name, sim, result.Metrics.BoxesInitial, result.Metrics.BoxesTextMerge, result.Metrics.BoxesVertMerge, len(result.Sections))
- } else {
- t.Errorf("FAIL %s: CharSim=%.1f%% (must be 100%%) boxes:%d->%d->%d->%d",
- name, sim, result.Metrics.BoxesInitial, result.Metrics.BoxesTextMerge, result.Metrics.BoxesVertMerge, len(result.Sections))
- }
- }
-
- if total == 0 {
- t.Skip("no charspy/ files found")
- }
- t.Logf("Pipeline parity: %d/%d passed", passed, total)
- if passed < total {
- t.Errorf("%d/%d parity tests failed — Go pipeline differs from Python", total-passed, total)
- }
-}
-
-// TestVMWhitespaceGapBridge reproduces the exact RAG PDF divergence
-// with synthetic boxes. A whitespace box (width > 0, gap just below
-// threshold) gets merged into a content box, extending its bottom by
-// the whitespace height. This flips the next gap from reject to merge,
-// creating a cascade that reduces the section count by 1.
-//
-// Go's whitespace pre-filter removes this box before VM, so the
-// bottom extension never happens and the cascade fails to start.
-func TestVMWhitespaceGapBridge(t *testing.T) {
- // Coordinates extracted from RAG PDF charspy data, "服务体系" region.
- boxes := []pdf.TextBox{
- // Content A: merged result of 3 preceding lines
- {X0: 37.6, X1: 491.0, Top: 339.35, Bottom: 382.39,
- Text: "生成文本再用standard分词建立索引", PageNumber: 1},
- // Whitespace: U+00A0 non-breaking space, has non-zero width
- {X0: 37.6, X1: 40.3, Top: 396.39, Bottom: 406.79,
- Text: " ", PageNumber: 1},
- // Content B: would be rejected without whitespace gap bridge
- {X0: 37.6, X1: 543.3, Top: 420.16, Bottom: 431.19,
- Text: "直接用rag分词建立索引", PageNumber: 1},
- // Content C: cascades after B merges
- {X0: 37.6, X1: 526.4, Top: 436.16, Bottom: 447.20,
- Text: "是在原文中并没有这样的文字", PageNumber: 1},
- }
-
- mh := 9.361 // RAG PDF char median
- thr := mh * 1.5
-
- // Run VM with whitespace PRESENT (Python-like, no pre-filter).
- // Python's while/pop merges whitespace at b_ position into b
- // (extending b.bottom), then compares same b against next content.
- // We simulate this by letting whitespace through gap/xov checks
- // and absorbing it into prev when the checks pass.
- vWithWS := func() int {
- bxs := make([]pdf.TextBox, len(boxes))
- copy(bxs, boxes)
- sort.Slice(bxs, func(i, j int) bool {
- if bxs[i].Top != bxs[j].Top {
- return bxs[i].Top < bxs[j].Top
- }
- return bxs[i].X0 < bxs[j].X0
- })
- out := make([]pdf.TextBox, 0, len(bxs))
- for i := 0; i < len(bxs); i++ {
- b := bxs[i]
- isWS := strings.TrimSpace(b.Text) == ""
- // Whitespace in b position (current box): pop (skip).
- // In Python: bxs.pop(i); continue; i stays.
- if isWS && len(out) == 0 {
- continue // nothing to extend
- }
- if isWS && len(out) > 0 {
- prev := &out[len(out)-1]
- gap := b.Top - prev.Bottom
- ov := util.OverlapX(prev, &b)
- // Python: gap passes AND xov passes → whitespace merged
- // into prev, extending bottom. i advances (Go for-loop).
- if gap <= thr && ov >= 0.3 {
- prev.Bottom = b.Bottom
- }
- continue
- }
- if len(out) == 0 {
- out = append(out, b)
- continue
- }
- prev := &out[len(out)-1]
- if prev.LayoutNo != b.LayoutNo {
- out = append(out, b)
- continue
- }
- gap := b.Top - prev.Bottom
- ov := util.OverlapX(prev, &b)
- if gap > thr {
- out = append(out, b)
- continue
- }
- if ov < 0.3 {
- out = append(out, b)
- continue
- }
- pt := strings.TrimSpace(prev.Text)
- bt := strings.TrimSpace(b.Text)
- prev.Text = strings.TrimSpace(strings.TrimRight(pt, " \t") + " " + strings.TrimLeft(bt, " \t"))
- prev.Bottom = b.Bottom
- if prev.X0 > b.X0 {
- prev.X0 = b.X0
- }
- if prev.X1 < b.X1 {
- prev.X1 = b.X1
- }
- }
- return len(out)
- }
-
- // Run VM with whitespace PRE-FILTERED (Go current behavior).
- vNoWS := func() int {
- bxs := make([]pdf.TextBox, 0, len(boxes))
- for _, b := range boxes {
- if strings.TrimSpace(b.Text) != "" {
- bxs = append(bxs, b)
- }
- }
- sort.Slice(bxs, func(i, j int) bool {
- if bxs[i].Top != bxs[j].Top {
- return bxs[i].Top < bxs[j].Top
- }
- return bxs[i].X0 < bxs[j].X0
- })
- out := make([]pdf.TextBox, 0, len(bxs))
- for i := 0; i < len(bxs); i++ {
- b := bxs[i]
- if len(out) == 0 {
- out = append(out, b)
- continue
- }
- prev := &out[len(out)-1]
- if prev.LayoutNo != b.LayoutNo {
- out = append(out, b)
- continue
- }
- gap := b.Top - prev.Bottom
- ov := util.OverlapX(prev, &b)
- if gap > thr {
- out = append(out, b)
- continue
- }
- if ov < 0.3 {
- out = append(out, b)
- continue
- }
- pt := strings.TrimSpace(prev.Text)
- bt := strings.TrimSpace(b.Text)
- prev.Text = strings.TrimSpace(strings.TrimRight(pt, " \t") + " " + strings.TrimLeft(bt, " \t"))
- prev.Bottom = b.Bottom
- if prev.X0 > b.X0 {
- prev.X0 = b.X0
- }
- if prev.X1 < b.X1 {
- prev.X1 = b.X1
- }
- }
- return len(out)
- }
-
- nWS := vWithWS()
- nNoWS := vNoWS()
- t.Logf("With whitespace (Python-like): %d sections", nWS)
- t.Logf("Without whitespace (Go pre-filter): %d sections", nNoWS)
- t.Logf("Gap without bridge: 420.16 - 382.39 = %.2f > %.2f = REJECT", 420.16-382.39, thr)
- t.Logf("Gap with bridge: 420.16 - 406.79 = %.2f < %.2f = MERGE", 420.16-406.79, thr)
-
- // The manual vWithWS (Python-like) and vNoWS (old Go pre-filter) still
- // differ — the mechanism is real. But production lyt.NaiveVerticalMerge now
- // handles whitespace inline (gap bridge), matching Python.
- if nWS == nNoWS {
- t.Error("Manual implementations should differ — the gap bridge mechanism is real")
- }
-
- // Verify production lyt.NaiveVerticalMerge matches vWithWS (Python behavior).
- mhMap := map[int]float64{1: mh}
- mwMap := map[int]float64{1: 5}
- vmResult := lyt.NaiveVerticalMerge(boxes, mhMap, mwMap, nil)
- t.Logf("lyt.NaiveVerticalMerge (production): %d sections", len(vmResult))
- if len(vmResult) != nWS {
- t.Errorf("lyt.NaiveVerticalMerge produced %d sections, want %d (Python-like with gap bridge)", len(vmResult), nWS)
- }
-}
diff --git a/internal/deepdoc/parser/pdf/table/table_layout_test.go b/internal/deepdoc/parser/pdf/table/table_layout_test.go
index cb24f1ade0..b363f4b58e 100644
--- a/internal/deepdoc/parser/pdf/table/table_layout_test.go
+++ b/internal/deepdoc/parser/pdf/table/table_layout_test.go
@@ -426,7 +426,8 @@ func TestFillCellTextFromBoxes_PreservesTSRText(t *testing.T) {
// has NO existing text, even a box with partial overlap (< 85% of box
// area inside the cell) fills the cell. Simulates real DeepDoc TSR
// where cell boundaries are approximate and box coordinates may have
-// slight offsets. Regression test for qa.pdf SKIP_OCR empty cells.
+// slight offsets. Regression test for qa.pdf empty cells with approximate
+// TSR boundaries (no image OCR required).
func TestFillCellTextFromBoxes_PartialOverlap(t *testing.T) {
// Empty cell (no TSR text). Box only has ~55% of its area inside
// the cell (spills across the boundary). Python's 0.3 threshold
diff --git a/internal/deepdoc/parser/pdf/table/table_parity_test.go b/internal/deepdoc/parser/pdf/table/table_parity_test.go
index 8937ce69b9..0be0ba37b5 100644
--- a/internal/deepdoc/parser/pdf/table/table_parity_test.go
+++ b/internal/deepdoc/parser/pdf/table/table_parity_test.go
@@ -16,7 +16,7 @@ import (
// If Go produces the same HTML as Python, the pipeline is correct
// and differences are from the engine layer (pdf_oxide vs pdfplumber).
func TestTableParityWithPythonBoxes(t *testing.T) {
- boxesDir := filepath.Join("testdata", "output", "py", "noocr", "table_boxes")
+ boxesDir := filepath.Join("testdata", "output", "py", "ocr", "table_boxes")
entries, err := os.ReadDir(boxesDir)
if err != nil {
t.Skipf("Python table_boxes not found — run dump_py_results.py first: %v", err)
diff --git a/internal/deepdoc/parser/pdf/table_extract_test.go b/internal/deepdoc/parser/pdf/table_extract_test.go
index 82a18147c3..d3a5c9e3e8 100644
--- a/internal/deepdoc/parser/pdf/table_extract_test.go
+++ b/internal/deepdoc/parser/pdf/table_extract_test.go
@@ -69,7 +69,6 @@ func TestProcessOneTable_AutoRotateNormalizesCellBounds(t *testing.T) {
autoRotate := true
cfg := pdf.DefaultParserConfig()
cfg.AutoRotateTables = &autoRotate
- cfg.SkipOCR = true
p := NewParser(cfg)
pageImg := image.NewRGBA(image.Rect(0, 0, 320, 220))
@@ -129,7 +128,6 @@ func TestProcessOneTable_AutoRotateNormalizesCellBounds(t *testing.T) {
// pre-fix code used w*0.03/h*0.03 here, diverging from Python.
func TestProcessOneTable_CropOffUsesFixedMargin(t *testing.T) {
cfg := pdf.DefaultParserConfig()
- cfg.SkipOCR = true
p := NewParser(cfg)
pageImg := image.NewRGBA(image.Rect(0, 0, 320, 220))
@@ -188,7 +186,6 @@ func TestProcessOneTable_NoPerCellOCR(t *testing.T) {
t.Run(fmt.Sprintf("autoRotate=%v", autoRotate), func(t *testing.T) {
cfg := pdf.DefaultParserConfig()
cfg.AutoRotateTables = &autoRotate
- cfg.SkipOCR = false
p := NewParser(cfg)
pageImg := image.NewRGBA(image.Rect(0, 0, 320, 220))
diff --git a/internal/deepdoc/parser/pdf/text_dump_test.go b/internal/deepdoc/parser/pdf/text_dump_test.go
index 428f7820b1..63957ced72 100644
--- a/internal/deepdoc/parser/pdf/text_dump_test.go
+++ b/internal/deepdoc/parser/pdf/text_dump_test.go
@@ -12,10 +12,10 @@ import (
)
// TestDumpTextOutput runs Parse on real PDFs and saves per-PDF text
-// to testdata/output/go/noocr/text/{pdf}.txt. Set DUMP_COUNT env to limit first N PDFs.
+// to testdata/output/go/ocr/text/{pdf}.txt. Set DUMP_COUNT env to limit first N PDFs.
func TestDumpTextOutput(t *testing.T) {
pdfDir := filepath.Join("testdata", "real_pdfs")
- outDir := filepath.Join("testdata", "output", "go", "noocr", "text")
+ outDir := filepath.Join("testdata", "output", "go", "ocr", "text")
os.MkdirAll(outDir, 0755)
entries, err := os.ReadDir(pdfDir)
diff --git a/internal/deepdoc/parser/pdf/tool/compare_test.go b/internal/deepdoc/parser/pdf/tool/compare_test.go
index 1fc7951c5c..0754f55021 100644
--- a/internal/deepdoc/parser/pdf/tool/compare_test.go
+++ b/internal/deepdoc/parser/pdf/tool/compare_test.go
@@ -13,8 +13,8 @@ import (
// TestBatchCompareWithPython compares Go output against Python reference
// across 4 dimensions (text, tables, DLA, TSR raw). It is read-only —
-// no generation, no CGO/DeepDoc dependency. Use BATCH_SKIP_OCR=1 to
-// compare the noocr variant; PY_OCR_SUFFIX to override the Python variant.
+// no generation, no CGO/DeepDoc dependency. Use PY_OCR_SUFFIX to override
+// the Python variant.
func TestBatchCompareWithPython(t *testing.T) {
level := slog.LevelInfo
if common.GetEnv(common.EnvBatchLogLevel) == "debug" {
@@ -26,9 +26,6 @@ func TestBatchCompareWithPython(t *testing.T) {
slog.SetDefault(slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: level})))
goVariant := "ocr"
- if common.GetEnv(common.EnvBatchSkipOCR) == "1" {
- goVariant = "noocr"
- }
pyVariant := common.GetEnv(common.EnvPYOCRSuffix)
if pyVariant == "" {
pyVariant = goVariant
diff --git a/internal/deepdoc/parser/pdf/tool/config.go b/internal/deepdoc/parser/pdf/tool/config.go
index 665379eba4..7d2c1248fc 100644
--- a/internal/deepdoc/parser/pdf/tool/config.go
+++ b/internal/deepdoc/parser/pdf/tool/config.go
@@ -12,7 +12,6 @@ import (
type Config struct {
Count int
Single string
- SkipOCR bool // DLA+TSR but no image OCR
CompareOnly bool
CompareFilter string
CSVOutput string
@@ -29,7 +28,6 @@ func LoadConfig() Config {
return Config{
Count: envInt(common.EnvBatchCount, 0),
Single: common.GetEnv(common.EnvBatchSingle),
- SkipOCR: common.GetEnv(common.EnvBatchSkipOCR) == "1",
CompareOnly: common.GetEnv(common.EnvBatchCompareOnly) == "1",
CompareFilter: common.GetEnv(common.EnvBatchCompareFilter),
CSVOutput: envStr(common.EnvBatchCompareCSV, filepath.Join(td, "output", fmt.Sprintf("compare_%s.csv", time.Now().Format("20060102_150405")))),
diff --git a/internal/deepdoc/parser/type/types.go b/internal/deepdoc/parser/type/types.go
index 428f23b838..3b57e8e390 100644
--- a/internal/deepdoc/parser/type/types.go
+++ b/internal/deepdoc/parser/type/types.go
@@ -212,7 +212,6 @@ type ParserConfig struct {
AutoRotateTables *bool
SeparateTablesFigs bool
SortByTop bool
- SkipOCR bool
// Pages restricts parsing to these 1-indexed inclusive page ranges.
// nil/empty means parse all pages. Ranges beyond the document are clamped
// at parse time; fully out-of-range ranges are skipped.
diff --git a/internal/parser/parser/pdf_parser_cgo.go b/internal/parser/parser/pdf_parser_cgo.go
index dc61d23859..8a957ae7c2 100644
--- a/internal/parser/parser/pdf_parser_cgo.go
+++ b/internal/parser/parser/pdf_parser_cgo.go
@@ -34,7 +34,6 @@ func (p *PDFParser) ParseWithResult(ctx context.Context, filename string, data [
return parsePDFWithTCADP(filename, data, p)
}
cfg := deepdoctype.DefaultParserConfig()
- cfg.SkipOCR = false
cfg.Pages = p.Pages
parser := deepdocpdf.NewParser(cfg)
res := parsePDFWithDeepDocOptions(ctx, filename, data, pdfPostProcessOptions{
diff --git a/internal/server/config/environments.go b/internal/server/config/environments.go
index aec564bffe..3b432ea5cb 100644
--- a/internal/server/config/environments.go
+++ b/internal/server/config/environments.go
@@ -72,7 +72,6 @@ type Environments struct {
DeepDocBatchSingle string `mapstructure:"deep_doc_batch_single"`
DeepDocBatchCount int `mapstructure:"deep_doc_batch_count"`
DeepDocBatchLogLevel string `mapstructure:"deep_doc_batch_log_level"`
- DeepDocSkipOCR bool `mapstructure:"deep_doc_skip_ocr"`
DeepDocCompareOnly bool `mapstructure:"deep_doc_compare_only"`
DeepDocCompareFilter string `mapstructure:"deep_doc_compare_filter"`
DeepDocCompareCSV string `mapstructure:"deep_doc_compare_csv"`
@@ -368,12 +367,6 @@ func (c *Config) GetEnvironments() error {
c.environments.DeepDocBatchLogLevel = DeepDocBatchLogLevelStr
}
- DeepDocBatchSkipOCRStr := common.GetEnv(common.EnvBatchSkipOCR)
- if DeepDocBatchSkipOCRStr != "" {
- DeepDocBatchSkipOCR := strings.ToLower(DeepDocBatchSkipOCRStr) == "true"
- c.environments.DeepDocSkipOCR = DeepDocBatchSkipOCR
- }
-
DeepDocBatchCompareOnlyStr := common.GetEnv(common.EnvBatchCompareOnly)
if DeepDocBatchCompareOnlyStr != "" {
DeepDocBatchCompareOnly := strings.ToLower(DeepDocBatchCompareOnlyStr) == "true"
@@ -699,10 +692,6 @@ func (c *Config) GetDeepDocBatchLogLevel() string {
return c.environments.DeepDocBatchLogLevel
}
-func (c *Config) GetDeepDocBatchSkipOCR() bool {
- return c.environments.DeepDocSkipOCR
-}
-
func (c *Config) GetDeepDocCompareOnly() bool {
return c.environments.DeepDocCompareOnly
}