Skip to content

Fix line clustering tolerance for rendered text directions - #1434

Open
ainuo-AI wants to merge 1 commit into
jsvine:developfrom
ainuo-AI:codex/fix-render-line-tolerance
Open

ainuo-AI wants to merge 1 commit into
jsvine:developfrom
ainuo-AI:codex/fix-render-line-tolerance

Conversation

@ainuo-AI

Copy link
Copy Markdown

When x_tolerance and y_tolerance differ, changing the output render direction can merge separate source lines in utils.extract_text and in extracted table cells. For example, two source lines containing A and B should render as AB with line_dir_render="ltr", char_dir_render="ttb"; the current code instead returns "A\n \nB" because it switches from the source y tolerance to the render x tolerance.

Select the clustering tolerance from extractor.line_dir, matching the coordinate key used to group words. Rendering then changes the output direction without changing which source lines are grouped. This is a one-line production fix with no new parameters or dependencies.

Tests cover all four source line directions and all eight render direction combinations, plus public Page.extract_table() extraction using the existing line-char-render-example.pdf fixture. Changelog and contributor credit are included.

Validation on Windows, CPython 3.12.10:

  • Unchanged develop with the new tests: 179 passed, 27 failed.
  • Fixed source with the same tests and environment: 196 passed, 10 failed.
  • All 33 new cases pass. The 17 additional baseline failures are resolved; no new failures appear.
  • The 10 remaining failures also occur before the fix: six repair tests cannot find Ghostscript, and four CLI tests fail on Windows newline differences.
  • Black checks pass for all 37 Python files individually; the multiprocess invocation hung in the local sandbox.
  • isort, Flake8, strict mypy, and git diff --check pass.
  • python setup.py build sdist passes.

The full suite has not been verified on Linux or on the other supported Python versions.

AI assistance was used to prepare this change and its regression tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant