Skip to content

fix: keep overlap labels aligned with boxes - #4445

Open
uczltw6 wants to merge 1 commit into
Unstructured-IO:mainfrom
uczltw6:uczltw6/fix-overlap-coordinate-alignment
Open

fix: keep overlap labels aligned with boxes#4445
uczltw6 wants to merge 1 commit into
Unstructured-IO:mainfrom
uczltw6:uczltw6/fix-overlap-coordinate-alignment

Conversation

@uczltw6

@uczltw6 uczltw6 commented Aug 19, 2026

Copy link
Copy Markdown

Summary

  • keep bounding boxes, element labels, and text content aligned when an element has no coordinates
  • preserve original element indexes in overlap reports
  • add a regression test covering a coordinate-less element before a nested pair

Problem

catch_overlapping_and_nested_bboxes() already excludes elements without coordinates from its bounding-box collection, but it still appended their labels and text to the parallel collections. A coordinate-less element therefore shifted those collections, causing later overlap and parent-child reports to name the wrong elements and content.

The fix appends all three values only for coordinate-bearing elements, so every index used by the overlap detector refers to the same source element.

Tests

  • python3 -m pytest test_unstructured/test_utils.py -q — 38 passed
  • python3 -m ruff check unstructured/utils.py test_unstructured/test_utils.py
  • python3 -m ruff format --check unstructured/utils.py test_unstructured/test_utils.py
  • git diff --check

AI assistance was used to help identify the edge case and prepare the focused patch. The behavior and test results were verified locally.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

Shadow auto-approve: would auto-approve. Fix catch_overlapping_and_nested_bboxes() so labels/text are only appended for coordinate-bearing elements, preventing index misalignment in overlap reports. Adds a regression test and bumps version/changelog.

Re-trigger cubic

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