mirror of
https://github.com/DS4SD/docling.git
synced 2025-07-27 04:24:45 +00:00
Update example export code
Signed-off-by: Christoph Auer <cau@zurich.ibm.com>
This commit is contained in:
parent
a50ba57a1f
commit
3f0b01702b
@ -13,7 +13,7 @@ from docling.document_converter import DocumentConverter
|
|||||||
_log = logging.getLogger(__name__)
|
_log = logging.getLogger(__name__)
|
||||||
|
|
||||||
USE_V2 = True
|
USE_V2 = True
|
||||||
USE_LEGACY = True
|
USE_LEGACY = False
|
||||||
|
|
||||||
|
|
||||||
def export_documents(
|
def export_documents(
|
||||||
@ -34,23 +34,11 @@ def export_documents(
|
|||||||
if USE_V2:
|
if USE_V2:
|
||||||
# Export Docling document format to JSON (experimental):
|
# Export Docling document format to JSON (experimental):
|
||||||
with (output_dir / f"{doc_filename}.json").open("w") as fp:
|
with (output_dir / f"{doc_filename}.json").open("w") as fp:
|
||||||
fp.write(
|
fp.write(json.dumps(conv_res.document.export_to_dict()))
|
||||||
json.dumps(
|
|
||||||
conv_res.document.model_dump(
|
|
||||||
mode="json", by_alias=True, exclude_none=True
|
|
||||||
)
|
|
||||||
)
|
|
||||||
) # TODO to be replaced with convenience method
|
|
||||||
|
|
||||||
# Export Docling document format to YAML (experimental):
|
# Export Docling document format to YAML (experimental):
|
||||||
with (output_dir / f"{doc_filename}.yaml").open("w") as fp:
|
with (output_dir / f"{doc_filename}.yaml").open("w") as fp:
|
||||||
fp.write(
|
fp.write(yaml.safe_dump(conv_res.document.export_to_dict()))
|
||||||
yaml.safe_dump(
|
|
||||||
conv_res.document.model_dump(
|
|
||||||
mode="json", by_alias=True, exclude_none=True
|
|
||||||
)
|
|
||||||
)
|
|
||||||
) # TODO to be replaced with convenience method
|
|
||||||
|
|
||||||
# Export Docling document format to doctags (experimental):
|
# Export Docling document format to doctags (experimental):
|
||||||
with (output_dir / f"{doc_filename}.doctags.txt").open("w") as fp:
|
with (output_dir / f"{doc_filename}.doctags.txt").open("w") as fp:
|
||||||
|
Loading…
Reference in New Issue
Block a user