Skip to content

Commit

Permalink
update key-link representations in document tokens
Browse files Browse the repository at this point in the history
Signed-off-by: Saidgurbuz <[email protected]>
  • Loading branch information
Saidgurbuz committed Feb 19, 2025
1 parent 1a1f32a commit 50e2181
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions docling_core/types/doc/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
DocItemLabel.REFERENCE,
DocItemLabel.PAGE_HEADER,
DocItemLabel.PAGE_FOOTER,
DocItemLabel.KEY_VALUE_REGION,
}

DOCUMENT_TOKENS_EXPORT_LABELS = DEFAULT_EXPORT_LABELS.copy()
Expand Down Expand Up @@ -1434,7 +1435,7 @@ def export_to_document_tokens(
)

for cell in self.graph.cells:
body += f"<{cell.label.value} id='{cell.cell_id}'>{new_line}"
body += f"<{cell.label.value}_{cell.cell_id}>{new_line}"
if cell.prov is not None:
body += self.get_location_tokens(
doc=doc,
Expand All @@ -1447,10 +1448,10 @@ def export_to_document_tokens(

if cell.cell_id in source_to_targets:
targets = source_to_targets[cell.cell_id]
targets_str = ",".join(str(t) for t in targets)
body += f"<links='{targets_str}'/>{new_line}"
for target in targets:
body += f"<link_{target}>{new_line}"

body += f"<{cell.label.value} id='{cell.cell_id}'>{new_line}"
body += f"</{cell.label.value}_{cell.cell_id}>{new_line}"

body += f"</{self.label.value}>{new_line}"

Expand Down

0 comments on commit 50e2181

Please sign in to comment.