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
feat: add inline formula block handling in layout processing
myhloli8d2cbfbc6707
diff --git a/mineru/backend/pipeline/pipeline_magic_model.py b/mineru/backend/pipeline/pipeline_magic_model.pyindex 95363ebf..11e3fa07 100644--- a/mineru/backend/pipeline/pipeline_magic_model.py+++ b/mineru/backend/pipeline/pipeline_magic_model.py@@ -11,6 +11,12 @@ class MagicModel:"""为所有模型数据添加bbox信息(缩放,poly->bbox)"""self.__fix_axis()+ @staticmethod+ def __is_inline_formula_block(layout_det: dict) -> bool:+ return (+ layout_det.get('label') == 'inline_formula'+ or layout_det.get('cls_id') == 15+ )def __fix_axis(self):need_remove_list = []@@ -30,6 +36,16 @@ class MagicModel:for need_remove in need_remove_list:layout_dets.remove(need_remove)+ next_index = 1+ for layout_det in layout_dets:+ if self.__is_inline_formula_block(layout_det):+ layout_det.pop('index', None)+ continue++ if 'index' in layout_det:+ layout_det['index'] = next_index+ next_index += 1+def __tie_up_category_by_distance_v3(self, subject_category_id, object_category_id):# 定义获取主体和客体对象的函数@@ -192,4 +208,4 @@ class MagicModel:for col in extra_col:block[col] = item.get(col, None)blocks.append(block)- return blocks\ No newline at end of file+ return blocks