Skip to content

Commit

Permalink
changed table repr. to otsl fixed new line
Browse files Browse the repository at this point in the history
Signed-off-by: Matteo-Omenetti <[email protected]>
  • Loading branch information
Matteo-Omenetti authored and Matteo-Omenetti committed Feb 3, 2025
1 parent 172ada9 commit af6f2b9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
17 changes: 1 addition & 16 deletions docling_core/types/doc/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -2452,7 +2452,7 @@ def close_lists(
def save_as_document_tokens(
self,
filename: Path,
delim: str = "\n\n",
delim: str = "\n",
from_element: int = 0,
to_element: int = sys.maxsize,
labels: set[DocItemLabel] = DEFAULT_EXPORT_LABELS,
Expand All @@ -2463,11 +2463,7 @@ def save_as_document_tokens(
add_page_index: bool = True,
# table specific flags
add_table_cell_location: bool = False,
add_table_cell_label: bool = True,
add_table_cell_text: bool = True,
# specifics
page_no: Optional[int] = None,
with_groups: bool = True,
):
r"""Save the document content to a DocumentToken format."""
out = self.export_to_document_tokens(
Expand All @@ -2482,9 +2478,7 @@ def save_as_document_tokens(
add_page_index=add_page_index,
# table specific flags
add_table_cell_location=add_table_cell_location,
add_table_cell_label=add_table_cell_label,
add_table_cell_text=add_table_cell_text,
# specifics
)

with open(filename, "w", encoding="utf-8") as fw:
Expand All @@ -2503,10 +2497,7 @@ def export_to_document_tokens(
add_page_index: bool = True,
# table specific flags
add_table_cell_location: bool = False,
add_table_cell_label: bool = True,
add_table_cell_text: bool = True,
# specifics
newline: bool = True,
) -> str:
r"""Exports the document content to a DocumentToken format.
Expand All @@ -2523,7 +2514,6 @@ def export_to_document_tokens(
:param add_content: bool: (Default value = True)
:param add_page_index: bool: (Default value = True)
:param # table specific flagsadd_table_cell_location: bool
:param add_table_cell_label: bool: (Default value = True)
:param add_table_cell_text: bool: (Default value = True)
:returns: The content of the document formatted as a DocTags string.
:rtype: str
Expand Down Expand Up @@ -2568,11 +2558,6 @@ def add_page_break(result, item, previous_page_no, delim, add_page_break):

return result, current_page_no

if newline:
delim = "\n"
else:
delim = ""

prev_level = 0 # Track the previous item's level

in_ordered_list: List[bool] = [] # False
Expand Down
7 changes: 3 additions & 4 deletions test/test_docling_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,9 @@ def _test_export_methods(doc: DoclingDocument, filename: str):

# Test DocTags export ...
dt_pred = doc.export_to_document_tokens()
# print("\n\n\n\n\n\n\n")
# print(filename)
# print(dt_pred)
# print("\n\n\n\n\n\n\n")
print("\n\n\n")
print(dt_pred)
print("\n\n\n")
_verify_regression_test(dt_pred, filename=filename, ext="dt")

# Test Tables export ...
Expand Down

0 comments on commit af6f2b9

Please sign in to comment.