Repository navigation
Conversation
|
✅ DCO Check Passed Thanks @wittjeff, all your commits are properly signed off. 🎉 |
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/
|
|
Tested on a real document, Innst. 240 S (2013–2014) of the Norwegian parliament (5 pages), with a build of 0983d9c on macOS arm64. Result: this PR keeps all 16 en dashes of the document, each in the same word as in the pdfium text layer, and changes nothing else.
For example, |
…cell text `text_constants::replacements` folded U+2012..U+2015 and U+2212 to `-` together with the hyphen variants U+2010 and U+2011. The fold is unconditional and `orig` is a copy of the folded text, so nothing downstream could recover an en dash in `pages 3–5` or a minus sign in `−3`. Only the two hyphen variants keep folding, because the line-joining dehyphenation in docling recognises an ASCII hyphen alone. Covers case 1 of docling-project#362. The ligature fallback (case 2) and the kerning-gap split (case 3) are separate code paths and will come as separate PRs. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Jeff Witt <1848307+wittjeff@users.noreply.github.com>
…tests The tests added with docling-project#395 expected U+2212 to fold to "-". This PR keeps the minus sign, so the three minus cases now expect U+2212. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Jeff Witt <1848307+wittjeff@users.noreply.github.com>
0983d9c to
3f252c6
Compare
Summary
The cell text sanitizer folded the whole dash block U+2010..U+2015 and the minus sign U+2212 to
-before any text left the parser. The fold runs outside thedo_sanitizationflag and the exportedorigfield is a copy of the folded text, so nothing downstream could recover the character. That changes meaning:pages 3–5and2024–2026(ranges) came out as3-5and2024-2026,Product — Nutshelllost its em dash, and a minus sign became a hyphen.Fixes case 1 of #362 (cases 2 and 3 are separate code paths, see the triage comment there).
Cause
text_constants::replacementsinsrc/parse/pdf_sanitators/constants.h, same table as #335 / #349.Change
Remove the U+2012, U+2013, U+2014, U+2015 and U+2212 entries. U+2010 (hyphen) and U+2011 (non-breaking hyphen) keep folding to
-: docling'sPageAssembleModel.sanitize_textjoins hyphenated line breaks by looking for an ASCII hyphen alone, and docling folds quotes itself but not dashes, so the dashes now reach theDoclingDocumentunchanged. Six lines plus a comment.Test
tests/test_unit_dash_sanitization.py, self-contained viatests/pdf_builder.py:/WinAnsiEncodingand no embedded program, with 0x96 (endash) and 0x97 (emdash), so the glyph decode is not in question: the issue's ownNutshell — pages 3–5case;orig == textcheck;/ToUnicodecovers U+2010..U+2015 and U+2212, checking that the two hyphen variants still fold and the five others are kept.Against
mainthe three dash tests fail with['Nutshell - pages 3-5']; with the change all five pass, andtests/test_unit_quote_sanitization.pyis unaffected.Regression set
Line-cell text of all 940 pages in the regression set (447 documents, pinned
HF_DATASET_REVISION), this branch againstmainbuilt from the same tree:3763025099401294496-2.pdfthat already differ onmain)The 228 pages carry U+2013 (en dash, most common), U+2014, U+2212 and U+2015 where the ground truth has
-; nothing else changes. The checked-in parser ground truth therefore needs a regeneration for those pages, as #361 did for its change. I did not touch the dataset.