Skip to content

Commit

Permalink
make table output explicit
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Staar <[email protected]>
  • Loading branch information
PeterStaar-IBM committed Oct 22, 2024
1 parent c78e8f1 commit a70898e
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions docling_core/types/doc/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -1397,7 +1397,9 @@ def export_to_document_tokens(

return doctags

def _export_to_indented_text(self, indent=" ", max_text_len: int = -1):
def _export_to_indented_text(
self, indent=" ", max_text_len: int = -1, explicit_tables: bool = False
):
"""Export the document to indented text to expose hierarchy."""
result = []

Expand Down Expand Up @@ -1477,15 +1479,16 @@ def get_text(text: str, max_text_len: int):
+ f"{caption.text}"
)

grid: list[list[str]] = []
for i, row in enumerate(item.data.grid):
grid.append([])
for j, cell in enumerate(row):
if j < 10:
text = get_text(text=cell.text, max_text_len=16)
grid[-1].append(text)
if explicit_tables:
grid: list[list[str]] = []
for i, row in enumerate(item.data.grid):
grid.append([])
for j, cell in enumerate(row):
if j < 10:
text = get_text(text=cell.text, max_text_len=16)
grid[-1].append(text)

result.append("\n" + tabulate(grid) + "\n")
result.append("\n" + tabulate(grid) + "\n")

elif isinstance(item, PictureItem):

Expand Down

0 comments on commit a70898e

Please sign in to comment.