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: implement removal of internal layout items from table processing in batch analysis
myhloli45c7b4b5b5a4
diff --git a/mineru/backend/pipeline/batch_analyze.py b/mineru/backend/pipeline/batch_analyze.pyindex 1b4c8085..2b524938 100644--- a/mineru/backend/pipeline/batch_analyze.py+++ b/mineru/backend/pipeline/batch_analyze.py@@ -235,6 +235,41 @@ class BatchAnalyze:return rich_items+ def _should_remove_table_internal_layout_item(+ self,+ layout_item: dict,+ table_bbox: list[float],+ ) -> bool:+ label = layout_item.get("label")+ if label not in {"display_formula", "inline_formula", *TABLE_RICH_IMAGE_LABELS}:+ return False++ item_bbox = layout_item.get("bbox")+ if item_bbox is None:+ return False++ center = self._bbox_center(item_bbox)+ return self._point_in_bbox(center, table_bbox, tolerance=0.5)++ def _remove_table_internal_layout_items(self, table_res_list_all_page: list[dict]) -> None:+ for table_res_dict in table_res_list_all_page:+ table_bbox = table_res_dict["table_res"].get("bbox")+ if table_bbox is None:+ continue++ page_layout_res = table_res_dict.get("page_layout_res")+ if not page_layout_res:+ continue++ page_layout_res[:] = [+ layout_item+ for layout_item in page_layout_res+ if not self._should_remove_table_internal_layout_item(+ layout_item,+ table_bbox,+ )+ ]+@staticmethoddef _match_cell_index(item_bbox: list[float], cell_bboxes: list[list[float]]) -> int | None:if not cell_bboxes:@@ -616,6 +651,8 @@ class BatchAnalyze:end_index = html_code.rfind("</table>") + len("</table>")table_res_dict["table_res"]["html"] = html_code[start_index:end_index]+ self._remove_table_internal_layout_items(table_res_list_all_page)+# OCR detif self.enable_ocr_det_batch:# 批处理模式 - 按语言和分辨率分组