Skip to content

Commit

Permalink
fix key-value cell location for doctags
Browse files Browse the repository at this point in the history
Signed-off-by: Saidgurbuz <[email protected]>
  • Loading branch information
Saidgurbuz committed Feb 25, 2025
1 parent 50e2181 commit 8900109
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions docling_core/types/doc/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -1419,6 +1419,10 @@ def export_to_document_tokens(
"""
body = f"<{self.label.value}>{new_line}"

page_no = 0
if len(self.prov) > 0:
page_no = self.prov[0].page_no

if add_location:
body += self.get_location_tokens(
doc=doc,
Expand All @@ -1437,12 +1441,15 @@ def export_to_document_tokens(
for cell in self.graph.cells:
body += f"<{cell.label.value}_{cell.cell_id}>{new_line}"
if cell.prov is not None:
body += self.get_location_tokens(
doc=doc,
new_line=new_line,
xsize=xsize,
ysize=ysize,
)
if len(doc.pages.keys()):
page_w, page_h = doc.pages[page_no].size.as_tuple()
body += DocumentToken.get_location(
bbox=cell.prov.bbox.to_bottom_left_origin(page_h).as_tuple(),
page_w=page_w,
page_h=page_h,
xsize=xsize,
ysize=ysize,
)
if add_content:
body += f"{cell.text.strip()}{new_line}"

Expand Down

0 comments on commit 8900109

Please sign in to comment.