Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.
Python ai4sciencedocument-analysisdocxextract-datalayout-analysisocrparserpdfpdf-converterpdf-extractor-llmpdf-extractor-pretrainpdf-extractor-ragpdf-parserpptxpythonxlsx
# add table recognition using struct-eqtable ## Changelog 31/07/20204 - Support table recognition. Table images will be converted into LaTex.
liukaiwend6c58ecca268
diff --git a/magic_pdf/dict2md/ocr_mkcontent.py b/magic_pdf/dict2md/ocr_mkcontent.pyindex 5465c799..880d7f60 100644--- a/magic_pdf/dict2md/ocr_mkcontent.py+++ b/magic_pdf/dict2md/ocr_mkcontent.py@@ -130,7 +130,7 @@ def ocr_mk_markdown_with_para_core_v2(paras_of_layout, mode, img_buket_path=""):if span['type'] == ContentType.Table:# if processed by table modelif span.get('content', ''):- para_text += f"\n {span['content']} \n"+ para_text += f"\n\n$\n {span['content']}\n$\n\n"else:para_text += f"\n}) \n"for block in para_block['blocks']: # 3rd.拼table_footnotediff --git a/magic_pdf/model/magic_model.py b/magic_pdf/model/magic_model.pyindex fec19294..970bd079 100644--- a/magic_pdf/model/magic_model.py+++ b/magic_pdf/model/magic_model.py@@ -561,13 +561,9 @@ class MagicModel:span["type"] = ContentType.Imageelif category_id == 5:# 获取table模型结果- html = layout_det.get("html", None)latex = layout_det.get("latex", None)- if html:- span["content"] = html- elif latex:+ if latex:span["content"] = latex-span["type"] = ContentType.Tableelif category_id == 13:span["content"] = layout_det["latex"]diff --git a/magic_pdf/model/pdf_extract_kit.py b/magic_pdf/model/pdf_extract_kit.pyindex b559e253..06e58e32 100644--- a/magic_pdf/model/pdf_extract_kit.py+++ b/magic_pdf/model/pdf_extract_kit.py@@ -287,13 +287,7 @@ class CustomPEKModel:end_time = time.time()run_time = end_time - start_timeprint(f"------------table recognition processing ends within {run_time}s-----")+ layout["latex"] = latex_code- # try to convert latex to html- try:- html_code = convert_text(latex_code, 'html', format='latex')- layout["html"] = html_code- except Exception as e:- layout["latex"] = latex_code- logger.error(f"[pdf_extract_kit][CustomPEKModel]: converting latex to html failed: {e}")return layout_res