Repository navigation
Keep minus signs that Cambridge fonts draw with unmapped glyphs - #301
Draft
thesanogoeffect wants to merge 1 commit into
Draft
thesanogoeffect wants to merge 1 commit into
thesanogoeffect wants to merge 1 commit into
Conversation
Cambridge's fonts (Psychological Medicine) draw the minus sign with a glyph they leave unmapped, so pdfium reports it as a control character (U+0001 or U+0003). bibr stripped it or sent the region to OCR, and negative statistics lost their sign: of the 98 negative statistics in 18 such papers of the JATS text benchmark, 0.9.3 kept 44 and --fast 10. A control glyph whose tight box is a thin bar along its baseline (at least 6 times as long as it is thick, measured along the char's angle so that a turned table page counts) is now read as U+2212 when the page's char records are built. The trace keeps the raw code and the record gets REC_UNMAPPED_MINUS. On the benchmark's 299 papers this changes 676 characters in 22 papers; all 547 that are followed by a number are a minus in the publisher's XML, and the page text of the 18 Cambridge papers now holds all 98 negative statistics.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #301 +/- ##
==========================================
- Coverage 91.03% 91.02% -0.01%
==========================================
Files 345 345
Lines 74575 74604 +29
Branches 13933 13939 +6
==========================================
+ Hits 67892 67911 +19
- Misses 4115 4122 +7
- Partials 2568 2571 +3 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
Requested by Jakub · project thread
Hotfix candidate for 0.9.3, found by the new text benchmark (bibr-validation
textbench/, branchclaude/project-thread-7o68t3).Problem
Cambridge's fonts (Psychological Medicine) draw the minus sign with a glyph they leave unmapped. pdfium reports it as a control character (U+0001, in one paper U+0003), which bibr strips, or which fails the native-text gate and sends the region to OCR. Negative statistics lose their sign: "t(41) = −2.31" can come out as "t(41) = 2.31". For Metacheck that flips the sign of a reported effect.
Fix
When the page's char records are built (
_page_char_records), a control glyph (C0, except NUL, STX and the whitespace controls) whose tight box is a thin bar along its baseline is read as U+2212. The bar must be at least 6 times as long as it is thick, measured alongFPDFText_GetCharAngle, so a landscape table on a turned page counts and a tall TeX extension piece does not. The record gets the new flagREC_UNMAPPED_MINUS, and the trace keeps the raw code. The default native-text regions, the--fasttext layer and the document layer's record text all read these records.Evidence (JATS text benchmark, 299 born-digital papers)
Negative statistics found character for character in the 18 Cambridge papers with the glyph:
--fastTests
tests/ocr/test_unmapped_minus.py(18 tests): a Type 3 font fixture that reproduces the unmapped glyphs (a bar at code 1, a square at code 5), the record flag and trace, the native-text gate, a/Rotate 90page, and the shape rule.tests/test_native_text.py,tests/ocr,tests/document: 1,656 passed.tests/structureand the export tests: 1,741 passed (both withoutslow). The full suite has not run.ruff check,ruff format --checkandscripts/check_public_tree.pypass.Not done
No end-to-end
bibr chewrun: the cloud session can't fetch the layout models. Re-running bibr default and--faston the 18 Cambridge papers on declan would confirm the end-to-end gain.Generated by Claude Code