mirror of
https://github.com/DS4SD/docling.git
synced 2025-12-08 20:58:11 +00:00
fix: translation example (#2166)
* fix: translation example Signed-off-by: shikharbhardwaj <8502456+shikharbhardwaj@users.noreply.github.com> * Fix translation example formatting Signed-off-by: shikharbhardwaj <8502456+shikharbhardwaj@users.noreply.github.com> --------- Signed-off-by: shikharbhardwaj <8502456+shikharbhardwaj@users.noreply.github.com>
This commit is contained in:
8
docs/examples/translate.py
vendored
8
docs/examples/translate.py
vendored
@@ -53,7 +53,7 @@ def main():
|
||||
|
||||
conv_res = doc_converter.convert(input_doc_path)
|
||||
conv_doc = conv_res.document
|
||||
doc_filename = conv_res.input.file
|
||||
doc_filename = conv_res.input.file.name
|
||||
|
||||
# Save markdown with embedded pictures in original text
|
||||
md_filename = output_dir / f"{doc_filename}-with-images-orig.md"
|
||||
@@ -66,8 +66,12 @@ def main():
|
||||
|
||||
elif isinstance(element, TableItem):
|
||||
for cell in element.data.table_cells:
|
||||
cell.text = translate(text=element.text)
|
||||
cell.text = translate(text=cell.text)
|
||||
|
||||
# Save markdown with embedded pictures in translated text
|
||||
md_filename = output_dir / f"{doc_filename}-with-images-translated.md"
|
||||
conv_doc.save_as_markdown(md_filename, image_mode=ImageRefMode.EMBEDDED)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user