You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 11, 2025. It is now read-only.
1. **Using a Separate List for Removal**: Instead of deleting elements from `text_alignment.textlines` while iterating over it, we first collect the indices of elements to remove in a separate list called `to_remove`. This prevents issues that can arise from modifying a list while iterating over it.
2. **Reverse Index Removal**: When removing items, we iterate over `to_remove` in reverse order. This ensures that the indices of elements to be removed do not affect the remaining elements in the list as we delete them.
3. **Clearer Condition for Removal**: The condition checking whether a text line is a singleton remains the same, but moving the deletion logic outside of the inner loop improves clarity and avoids potential errors that could lead to infinite loops.
4. **Termination Flag**: The loop continues as long as `removed_singletons` is `True`, which indicates that at least one text line has been removed in the last iteration. If no text lines are removed in a complete pass through the alignments, the loop will exit.
5. **Recomputing Alignments**: The line `self._textline_to_alignments = {}` is retained to clear the cache of alignments before recomputing them. This ensures that the latest state is reflected after modifications.
0 commit comments