Repository navigation
Conversation
A line break between two Han, kana or CJK/full-width punctuation characters is not a word boundary, so sanitize_text no longer inserts a space there. Clusters that contain Hangul keep the space, since Korean separates words with spaces. Part B of docling-project#4672. Signed-off-by: kevin9327 <5299031+kevin9327@users.noreply.github.com>
|
✅ DCO Check Passed Thanks @kevin9327, 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/
|
AI triage (advisory)Checked commit The PR changes CI safety: no concern found. A maintainer must still approve CI. 1 related pull request(s) in the same code
The |
There was a problem hiding this comment.
AI first review (advisory): no blocker found
This review covers the full diff at 1a902ea5c8. It read the code and did not run it.
The CJK join logic in sanitize_text is correct for the cases I traced, and the tests cover it. The main problem is scope: the PR also reformats Markdown code blocks in four usage-skill files, and none of that is mentioned in the description. Ask the author to remove those changes.
A maintainer makes the merge decision. This review never approves the pull request.
| # 1. JSON-ish string | ||
| result = extractor.extract(source="invoice.pdf", | ||
| template='{"bill_no": "string", "total": "float"}') | ||
| result = extractor.extract( |
There was a problem hiding this comment.
suggestion: Unrelated reformatting of four usage-skill files
The PR changes only code-block formatting in extraction.md, python-sdk.md, rag.md and service-client.md. It re-wraps lines, changes comment spacing and adds blank lines. None of this relates to CJK line joining, and the description does not mention it. These files are shipped in the wheel. They also overlap with open PRs #4218, #4496 and #4752, so the churn will cause merge conflicts for those PRs. Revert these four files and keep the PR to page_assemble_model.py and its test. If a formatter hook caused the changes, open a separate PR for them.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Keep this PR to the CJK line-join change in sanitize_text. Signed-off-by: kevin9327 <5299031+kevin9327@users.noreply.github.com>
There was a problem hiding this comment.
AI first review (advisory): no blocker found
This review covers the changes since 1a902ea5c8 at 130bb27ffc. It read the code and did not run it.
The new commit only reverts the Markdown formatting changes in the four usage-skill files. The PR is now back to page_assemble_model.py and its test. I found no new defect in the incremental changes.
Earlier findings
- fixed (suggestion): Unrelated reformatting of four usage-skill files
A maintainer makes the merge decision. This review never approves the pull request.
Part B of #4672 (the docling-side change; part A in docling-parse is independent).
Problem
PageAssembleModel.sanitize_textjoins every line break of a cluster with" ". Chinese and Japanese put no spaces between words, so every wrapped line of a horizontal CJK paragraph gets a spurious space in the middle of a word or sentence (地方公共団 体,准确识别版面结构并保留表格、公式和阅读顺序, 从而…).Change
_CJK_NO_SPACE_RE; covers Extensions A–H, compatibility ideographs, half-width katakana, vertical punctuation forms).대한민국 憲法 第一條) are space-separated words too. This also leaves the Korean ground truth (normal_4pages) untouched.docling は/PDF,令和元年/10月) still get a space; hyphenation handling is unchanged.Verification
tests/test_page_assemble_model.py: 17 new cases (Japanese, Chinese, full-width punctuation, half-width katakana, Ext-B ideograph, multi-line, mixed Latin/CJK, digits, Korean, Korean+Hanja, hyphenation, empty line). 6 of them fail onmain; all 56 pass with this change.End to end, standard PDF pipeline (no OCR) on a horizontal PDF rendered with Noto Serif CJK, counting spaces between two CJK characters in the output:
Cost of
sanitize_texton an 8-line cluster (best of 5 × 20k): Latin 2.75 → ~3.1–3.5 µs, Japanese 2.5 → 7.0 µs (that path now does the real work). Negligible next to the layout model per page.ruff format/ruff checkclean; mypy reports only the pre-existingFigureElementerror onmain.Vertical text (part A) and vertical reading order remain out of scope.