(container_el, doc, obj, pelem)
| 330 | |
| 331 | |
| 332 | def _add_child_elements(container_el, doc, obj, pelem): |
| 333 | payload = obj.get("payload") |
| 334 | if payload is not None: |
| 335 | children = payload.get("children", []) |
| 336 | |
| 337 | for child in children: |
| 338 | c_label = DocItemLabel(child["label"]) |
| 339 | c_bbox = BoundingBox.model_validate(child["bbox"]).to_bottom_left_origin( |
| 340 | doc.pages[pelem["page"]].size.height |
| 341 | ) |
| 342 | c_text = " ".join( |
| 343 | [ |
| 344 | cell["text"].replace("\x02", "-").strip() |
| 345 | for cell in child["cells"] |
| 346 | if len(cell["text"].strip()) > 0 |
| 347 | ] |
| 348 | ) |
| 349 | |
| 350 | c_prov = ProvenanceItem( |
| 351 | page_no=pelem["page"], charspan=(0, len(c_text)), bbox=c_bbox |
| 352 | ) |
| 353 | if c_label == DocItemLabel.LIST_ITEM: |
| 354 | # TODO: Infer if this is a numbered or a bullet list item |
| 355 | doc.add_list_item(parent=container_el, text=c_text, prov=c_prov) |
| 356 | elif c_label == DocItemLabel.SECTION_HEADER: |
| 357 | doc.add_heading(parent=container_el, text=c_text, prov=c_prov) |
| 358 | else: |
| 359 | doc.add_text( |
| 360 | parent=container_el, label=c_label, text=c_text, prov=c_prov |
| 361 | ) |
no test coverage detected
searching dependent graphs…