Skip to content

table: preserve decimal points with quad corrections disabled - #5204

Closed
Don-Yin wants to merge 3 commits into
pymupdf:mainfrom
Don-Yin:fix-table-decimal-points-5198
Closed

Don-Yin wants to merge 3 commits into
pymupdf:mainfrom
Don-Yin:fix-table-decimal-points-5198

Conversation

@Don-Yin

@Don-Yin Don-Yin commented Oct 23, 2026

Copy link
Copy Markdown

I reproduced the small table in #5198: with quad corrections disabled, 0.74 became '0 74\n.'. I saw this in default mode too: the existing '33043530\n, .' expectation became '330,435.30'.

I used extraction flags to get font-metric boxes for character grouping, without changing the global quad setting. I kept the existing accurate TextPage for layout. I added a rotated-table regression and corrected existing expectations that contained displaced punctuation. I left the separate extra-column issue unchanged.

I ran pytest tests: lite passed; the full distribution had only test_4392 failing, which also fails on unmodified main. The table suite passed with layout alone and with layout + 4llm.

Refs #5198.

Table extraction before and after the change

Signed-off-by: Don Yin <Don_Yin@outlook.com>
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@Don-Yin

Don-Yin commented Oct 23, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@veget-able

Copy link
Copy Markdown
Collaborator

Thanks for working on this and for the regression coverage.

I've opened #5243 for the same symptom. It groups and orders cell text by line coordinates derived from font metrics and keeps the existing glyph boxes, so there is no second text extraction and cell membership and detection read the same boxes as before. The PR body links here and describes how the two approaches differ.

My concern with replacing the character boxes is its reach. Those boxes also drive cell membership and the text-strategy edges, and Table.extract() and to_markdown() would then work from different geometry. I haven't confirmed a regression from that, but I'd rather fix the grouping without touching the boxes if that holds up.

Given the overlap, I'd suggest comparing the two approaches before either is merged. I'd welcome your view on #5243, especially any case your change handles that it misses.

@Don-Yin

Don-Yin commented Nov 3, 2026

Copy link
Copy Markdown
Author

Thanks, I cross-ran both test sets on the current release. #5243 passes my test_5198 cases (including the rotated ones) and my updated test_tables.py expectations. My branch passes your behavioural tests in test_5198.py; only the two line_top unit tests fail, since that helper doesn't exist on my side. So I didn't find a case mine covers that yours misses.

Mine is a smaller diff, but it does a second rawdict extraction, and your point about the boxes also driving cell membership is fair. I'm happy for the maintainers to pick #5243 and I'll close this one if they do.

@JorjMcKie

Copy link
Copy Markdown
Collaborator

@Don-Yin Please resolve the conflicts with the base so we can finally merge.

@veget-able

Copy link
Copy Markdown
Collaborator

@JorjMcKie One note before this gets rebased. #5243 went in today and fixes the same symptom. So I think main already has this fix.

@Don-Yin

Don-Yin commented Nov 5, 2026

Copy link
Copy Markdown
Author

Thanks @veget-able, you're right. I checked current main with #5243 on the #5198 cases and the rotated-table test from this PR, and they all come out correct without my change, so I'll close this one. Thanks @JorjMcKie for looking at it.

@Don-Yin Don-Yin closed this Nov 5, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants