fix(deepdoc): recover word boundaries for non-Latin scripts; skip OCR fallback the recogniser can't serve (#16958)

This commit is contained in:
deadtrickster
2026-07-17 19:36:25 +03:00
committed by GitHub
parent 8ebdc02cf6
commit 982b9c7b25
7 changed files with 345 additions and 34 deletions

View File

@@ -273,10 +273,12 @@ func (p *Parser) buildTextBoxes(ctx context.Context, pageImg image.Image,
}
}
}
// PUA / unmapped-glyph garbage: genuine noise, re-OCR regardless of script.
if totalCnt > 0 && float64(garbledCnt)/float64(totalCnt) >= 0.5 {
tb.Text = ""
}
if tb.Text != "" && util.IsGarbledByFontEncoding(boxChars[i], 5) {
} else if tb.Text != "" && util.OcrCanRepresent(tb.Text) && util.IsGarbledByFontEncoding(boxChars[i], 5) {
// Font-encoding garbling, but skipped for a script the recogniser
// cannot spell -- OCR would only produce garbage.
tb.Text = ""
}
}