fix: compare .label in predict_merges skip loop, not element object#153
Closed
Frank-Schruefer wants to merge 2 commits into
Closed
Conversation
In predict_merges, the while loop intended to skip over non-text elements
(headers, footers, tables, pictures, captions, footnotes) compared the
PageElement object itself against a list of DocItemLabel enum values:
sorted_elements[ind_p1] in [DocItemLabel.PAGE_HEADER, ...]
This comparison always evaluates to False, so the skip loop never
advanced — interrupting elements were never skipped. Fix by comparing
the element's label attribute instead:
sorted_elements[ind_p1].label in [DocItemLabel.PAGE_HEADER, ...]
Signed-off-by: stone <frank.schruefer@t-online.de>
Contributor
|
✅ DCO Check Passed Thanks @Frank-Schruefer, all your commits are properly signed off. 🎉 |
Contributor
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
nikos-livathinos
previously approved these changes
Apr 7, 2026
Signed-off-by: stone <frank.schruefer@t-online.de>
nikos-livathinos
approved these changes
Apr 17, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Member
|
This PR is superseded by #156 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
In
predict_merges, thewhileloop is intended to skip over interrupting elements (page headers, footers, tables, pictures, captions, footnotes) between two TEXT elements before deciding whether to merge them.The loop condition compared the
PageElementobject itself against a list ofDocItemLabelenum values:Since a
PageElementinstance is never equal to aDocItemLabelenum value, this comparison always evaluates toFalse— the skip loop never advances and interrupting elements are never skipped.Fix
Compare the element's
.labelattribute instead: