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 new drop scene
赵小蒙2f13b3a87cc5
diff --git a/magic_pdf/libs/drop_reason.py b/magic_pdf/libs/drop_reason.pyindex 7d6c1d94..9f574fc2 100644--- a/magic_pdf/libs/drop_reason.py+++ b/magic_pdf/libs/drop_reason.py@@ -23,4 +23,5 @@ class DropReason:PSEUDO_SINGLE_COLUMN = "pseudo_single_column" # 无法精确判断文字分栏CAN_NOT_DETECT_PAGE_LAYOUT="can_not_detect_page_layout" # 无法分析页面的版面NEGATIVE_BBOX_AREA = "negative_bbox_area" # 缩放导致 bbox 面积为负+ OVERLAP_BLOCKS_CAN_NOT_SEPARATION = "overlap_blocks_can_t_separation" # 无法分离重叠的block\ No newline at end of filediff --git a/magic_pdf/pdf_parse_union_core.py b/magic_pdf/pdf_parse_union_core.pyindex 39bee1fe..89eb9e37 100644--- a/magic_pdf/pdf_parse_union_core.py+++ b/magic_pdf/pdf_parse_union_core.py@@ -130,13 +130,16 @@ def parse_page_core(pdf_docs, magic_model, page_id, pdf_bytes_md5, imageWriter,'''将所有区块的bbox整理到一起'''if len(interline_equation_blocks) > 0:- all_bboxes, all_discarded_blocks = ocr_prepare_bboxes_for_layout_split(+ all_bboxes, all_discarded_blocks, drop_reasons = ocr_prepare_bboxes_for_layout_split(img_blocks, table_blocks, discarded_blocks, text_blocks, title_blocks,interline_equation_blocks, page_w, page_h)else:- all_bboxes, all_discarded_blocks = ocr_prepare_bboxes_for_layout_split(+ all_bboxes, all_discarded_blocks, drop_reasons = ocr_prepare_bboxes_for_layout_split(img_blocks, table_blocks, discarded_blocks, text_blocks, title_blocks,interline_equations, page_w, page_h)+ if len(drop_reasons) > 0:+ need_drop = True+ drop_reason = DropReason.OVERLAP_BLOCKS_CAN_NOT_SEPARATION'''先处理不需要排版的discarded_blocks'''discarded_block_with_spans, spans = fill_spans_in_blocks(all_discarded_blocks, spans, 0.4)diff --git a/magic_pdf/pre_proc/ocr_detect_all_bboxes.py b/magic_pdf/pre_proc/ocr_detect_all_bboxes.pyindex c05027da..f2edaa6a 100644--- a/magic_pdf/pre_proc/ocr_detect_all_bboxes.py+++ b/magic_pdf/pre_proc/ocr_detect_all_bboxes.py@@ -51,7 +51,7 @@ def ocr_prepare_bboxes_for_layout_split(img_blocks, table_blocks, discarded_bloc'''将剩余的bbox做分离处理,防止后面分layout时出错'''all_bboxes, drop_reasons = remove_overlap_between_bbox_for_block(all_bboxes)- return all_bboxes, all_discarded_blocks+ return all_bboxes, all_discarded_blocks, drop_reasonsdef fix_text_overlap_title_blocks(all_bboxes):