Repository navigation
fix(ocr): keep tesseract CLI words like "N/A" and numbers verbatim - #4536
Merged
PeterStaar-IBM merged 1 commit intoOct 7, 2026
Conversation
pd.read_csv parsed tesseract's TSV with the default NA handling and type
inference, so words such as "N/A", "None" or "null" became NaN and were
filtered out, and an OCR region with only numeric words came back as
floats ("007" -> "7.0"). Read the text column as plain strings.
Resolves docling-project#4535
Signed-off-by: Waleed Khalid <wak327@gmail.com>
Contributor
Author
|
@dolfim-ibm @cau-git could you take a look? The TSV parsing comes from the original tesseract CLI model (#118). The |
Contributor
|
✅ DCO Check Passed Thanks @wak327, all your commits are properly signed off. 🎉 |
Contributor
Merge Protections🟢 Merge protection satisfied — ready to merge. Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TesseractOcrCliModel._run_tesseractparsed tesseract's TSV output with pandas' default NA handling and type inference:N/A,NA,None,nullornanwere read as NaN and then dropped by thenotna()filter;textcolumn was inferred as float, so007became7.0and2024became2024.0.The
read_csvcall now passesdtype={"text": str}andkeep_default_na=False, so the text column holds exactly what tesseract printed. Rows without text are still removed by the existing empty-string filter. The numeric columns are always populated in tesseract's TSV, so they are unaffected.The new test feeds
_run_tesseractthe TSV tesseract prints forPrice N/A NA None null nanand for007 2024 12(through a patchedsubprocess.run, like the existing language tests) and checks the words come back unchanged. Onmainthe first case returns only['Price']and the second[7.0, 2024.0, 12.0].Issue resolved by this Pull Request:
Resolves #4535
Checklist: