From 3f0b01702bad3a12c5be0c12929574bb2f6b9429 Mon Sep 17 00:00:00 2001 From: Christoph Auer Date: Mon, 14 Oct 2024 16:40:40 +0200 Subject: [PATCH] Update example export code Signed-off-by: Christoph Auer --- examples/batch_convert.py | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/examples/batch_convert.py b/examples/batch_convert.py index f2887595..bbd4a9a0 100644 --- a/examples/batch_convert.py +++ b/examples/batch_convert.py @@ -13,7 +13,7 @@ from docling.document_converter import DocumentConverter _log = logging.getLogger(__name__) USE_V2 = True -USE_LEGACY = True +USE_LEGACY = False def export_documents( @@ -34,23 +34,11 @@ def export_documents( if USE_V2: # Export Docling document format to JSON (experimental): with (output_dir / f"{doc_filename}.json").open("w") as fp: - fp.write( - json.dumps( - conv_res.document.model_dump( - mode="json", by_alias=True, exclude_none=True - ) - ) - ) # TODO to be replaced with convenience method + fp.write(json.dumps(conv_res.document.export_to_dict())) # Export Docling document format to YAML (experimental): with (output_dir / f"{doc_filename}.yaml").open("w") as fp: - fp.write( - yaml.safe_dump( - conv_res.document.model_dump( - mode="json", by_alias=True, exclude_none=True - ) - ) - ) # TODO to be replaced with convenience method + fp.write(yaml.safe_dump(conv_res.document.export_to_dict())) # Export Docling document format to doctags (experimental): with (output_dir / f"{doc_filename}.doctags.txt").open("w") as fp: