Commit 051dfc1
committed
refactor(ls_tools): remove H1, H2, H4 heuristics — explicit annotation contract
Replace the three highest-value geometric heuristics in the Label Studio →
DoclingDocument pipeline with explicit annotation-driven lookups:
H1 (parent resolution via containment tree):
- Build `children_by_parent` dict from `parent_ls_id` on rectangle regions
- `_determine_parent` and `_has_unresolved_parent` become direct dict lookups
- Remove `build_containment_tree`, `ls_element_to_cvat_element`, `_find_tree_node`,
`containment_tree`/`tree_index` fields, and CVATElement/TreeNode imports
H2 (table structure discovery via bbox containment):
- `_create_table` uses `children_by_parent.get(element.ls_id)` instead of tree walk
- Table structure elements still consumed geometrically by `compute_cells` (unchanged)
H4 (list boundary detection via level comparison):
- `should_terminate_list`: remove level-based fallback — group path is the only
boundary signal; element outside active group terminates the list
- `shtart_list`: remove level-comparison block; warn on list_item with no group
H1 reading order (child paths):
- `build_global_reading_order` restructured with DFS splice: child paths
(polyline `level > 1`) are spliced immediately after their parent element
- Validation warnings for mismatched parent_ls_id and level/path-type mismatches
H5 (_process_remaining_children) simplifies naturally:
- Elements with no `parent_ls_id` absent from reading order are dropped with a warning
instead of silently added at root
Signed-off-by: Christoph Auer <cau@zurich.ibm.com>1 parent 2e8b209 commit 051dfc1
2 files changed
Lines changed: 111 additions & 144 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
| 126 | + | |
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | 134 | | |
152 | 135 | | |
153 | 136 | | |
| |||
171 | 154 | | |
172 | 155 | | |
173 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
174 | 164 | | |
175 | 165 | | |
176 | 166 | | |
177 | 167 | | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | 168 | | |
192 | 169 | | |
193 | 170 | | |
| |||
0 commit comments