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
refactor: group Flash PDF and Office implementations
myhlolie1c72fc6d3cf
diff --git a/mineru/model/flash/__init__.py b/mineru/model/flash/__init__.pyindex 404d9f81..33b34bab 100644--- a/mineru/model/flash/__init__.py+++ b/mineru/model/flash/__init__.py@@ -2,6 +2,6 @@"""Flash PDF 与 Office 模型公开入口。"""-from .model import DocModel, DocxModel, PdfModel, PptModel, PptxModel, XlsModel, XlsxModel+from .models import DocModel, DocxModel, PdfModel, PptModel, PptxModel, XlsModel, XlsxModel__all__ = ["PdfModel", "DocModel", "DocxModel", "PptModel", "PptxModel", "XlsModel", "XlsxModel"]diff --git a/mineru/model/flash/_shared/__init__.py b/mineru/model/flash/_shared/__init__.pynew file mode 100644index 00000000..0f2e49ec--- /dev/null+++ b/mineru/model/flash/_shared/__init__.py@@ -0,0 +1,4 @@+# Copyright (c) Opendatalab. All rights reserved.+"""Flash PDF 与 Office 复用的轻量算法。"""++__all__: list[str] = []diff --git a/mineru/model/flash/xycut.py b/mineru/model/flash/_shared/xycut.pysimilarity index 100%rename from mineru/model/flash/xycut.pyrename to mineru/model/flash/_shared/xycut.pydiff --git a/mineru/model/flash/model.py b/mineru/model/flash/models.pysimilarity index 86%rename from mineru/model/flash/model.pyrename to mineru/model/flash/models.pyindex 0c5cb480..b9d38a37 100644--- a/mineru/model/flash/model.py+++ b/mineru/model/flash/models.py@@ -4,11 +4,10 @@from __future__ import annotations-from typing import Any, BinaryIO+from typing import TYPE_CHECKING, Any, BinaryIO-from mineru.utils.pdf_document import PDFDocument--from .native_pdf import pipeline+if TYPE_CHECKING:+ from .pdf.document import PDFDocumentclass PdfModel:@@ -16,6 +15,7 @@ class PdfModel:def predict(self, pdf_doc: PDFDocument) -> list[list[dict[str, Any]]]:"""分析调用方持有的 PDFDocument,并原样返回分页 model_list。"""+ from .pdf import pipelinereturn pipeline._analyze_native_document(pdf_doc)@@ -27,7 +27,7 @@ class DocxModel:"""转换调用方持有的 DOCX 二进制流,并返回分页 model_list。"""# 延迟加载 Converter,避免纯 PDF 路径提前加载 Office 依赖。- from .docx.docx_converter import DocxConverter+ from .office.docx.docx_converter import DocxConverterconverter = DocxConverter()converter.convert(file_binary)@@ -41,7 +41,7 @@ class DocModel:"""转换调用方持有的 DOC 二进制流,并返回逐 section model-list。"""# 延迟加载旧版 DOC 解析器,避免其他格式提前加载 olefile。- from .doc.doc_converter import DocConverter+ from .office.doc.doc_converter import DocConverterconverter = DocConverter()converter.convert(file_binary)@@ -55,7 +55,7 @@ class PptxModel:"""转换调用方持有的 PPTX 二进制流,并返回分页 model_list。"""# 延迟加载 Converter,避免纯 PDF 路径提前加载 Office 依赖。- from .pptx.pptx_converter import PptxConverter+ from .office.pptx.pptx_converter import PptxConverterconverter = PptxConverter()converter.convert(file_binary)@@ -69,7 +69,7 @@ class PptModel:"""转换调用方持有的 PPT 二进制流,并返回逐幻灯片 model-list。"""# 延迟加载旧版 PPT 解析器,避免其他格式提前加载 olefile。- from .ppt.ppt_converter import PptConverter+ from .office.ppt.ppt_converter import PptConverterconverter = PptConverter()converter.convert(file_binary)@@ -83,7 +83,7 @@ class XlsModel:"""转换调用方持有的 XLS 二进制流,并返回逐工作表 model-list。"""# 延迟加载旧版 XLS 解析器,避免其他格式提前加载 olefile/openpyxl。- from .xls.xls_converter import XlsConverter+ from .office.xls.xls_converter import XlsConverterconverter = XlsConverter()converter.convert(file_binary)@@ -97,7 +97,7 @@ class XlsxModel:"""转换调用方持有的 XLSX 二进制流,并返回分页 model_list。"""# 延迟加载 Converter,避免纯 PDF 路径提前加载 Office 依赖。- from .xlsx.xlsx_converter import XlsxConverter+ from .office.xlsx.xlsx_converter import XlsxConverterconverter = XlsxConverter()converter.convert(file_binary)diff --git a/mineru/model/flash/office/__init__.py b/mineru/model/flash/office/__init__.pyindex 987b6c08..f94f2b1f 100644--- a/mineru/model/flash/office/__init__.py+++ b/mineru/model/flash/office/__init__.py@@ -1 +1,4 @@+# Copyright (c) Opendatalab. All rights reserved."""Flash Office 模型共享实现。"""++__all__: list[str] = []diff --git a/mineru/model/flash/doc/__init__.py b/mineru/model/flash/office/doc/__init__.pysimilarity index 81%rename from mineru/model/flash/doc/__init__.pyrename to mineru/model/flash/office/doc/__init__.pyindex f6a747e1..73da6cd6 100644--- a/mineru/model/flash/doc/__init__.py+++ b/mineru/model/flash/office/doc/__init__.py@@ -2,3 +2,4 @@"""Word 97–2003 二进制文档解析实现。"""+__all__: list[str] = []diff --git a/mineru/model/flash/doc/bookmarks.py b/mineru/model/flash/office/doc/bookmarks.pysimilarity index 100%rename from mineru/model/flash/doc/bookmarks.pyrename to mineru/model/flash/office/doc/bookmarks.pydiff --git a/mineru/model/flash/doc/doc_converter.py b/mineru/model/flash/office/doc/doc_converter.pysimilarity index 97%rename from mineru/model/flash/doc/doc_converter.pyrename to mineru/model/flash/office/doc/doc_converter.pyindex b489d33e..ba97db0f 100644--- a/mineru/model/flash/doc/doc_converter.py+++ b/mineru/model/flash/office/doc/doc_converter.py@@ -8,14 +8,14 @@ from html import escapeimport refrom typing import Any, BinaryIO, Iterable-from mineru.model.flash.legacy_office import BoundedOleReader, LegacyOfficeEncryptedError-from mineru.model.flash.office.image import serialize_office_image-from mineru.model.office_stream import read_stream_bytes_from_start-from mineru.types import RAW_CAPTION, BlockType-from mineru.utils.office_rich_text import OfficeRichTextSegment, build_rich_text_from_segments+from ..legacy import BoundedOleReader, LegacyOfficeEncryptedError+from ..image import serialize_office_image+from ..legacy.stream import read_stream_bytes_from_start+from .....types import RAW_CAPTION, BlockType+from ..rich_text import OfficeRichTextSegment, build_rich_text_from_segmentsfrom .fib import parse_fib-from mineru.model.flash.legacy_office.mtef import read_object_pool_equations+from ..legacy.mtef import read_object_pool_equationsfrom ..xls.embedded_chart import extract_embedded_chart_htmlfrom .models import (DocCharStyle,diff --git a/mineru/model/flash/doc/fib.py b/mineru/model/flash/office/doc/fib.pysimilarity index 99%rename from mineru/model/flash/doc/fib.pyrename to mineru/model/flash/office/doc/fib.pyindex 002a2043..9603f6da 100644--- a/mineru/model/flash/doc/fib.py+++ b/mineru/model/flash/office/doc/fib.py@@ -7,7 +7,7 @@ from __future__ import annotationsfrom dataclasses import dataclassimport struct-from mineru.model.flash.legacy_office import LegacyOfficeMalformedError+from ..legacy import LegacyOfficeMalformedErrorFIB_IDENT = 0xA5ECMIN_WORD97_NFIB = 0x00C1diff --git a/mineru/model/flash/doc/fields.py b/mineru/model/flash/office/doc/fields.pysimilarity index 100%rename from mineru/model/flash/doc/fields.pyrename to mineru/model/flash/office/doc/fields.pydiff --git a/mineru/model/flash/doc/formatting.py b/mineru/model/flash/office/doc/formatting.pysimilarity index 100%rename from mineru/model/flash/doc/formatting.pyrename to mineru/model/flash/office/doc/formatting.pydiff --git a/mineru/model/flash/doc/images.py b/mineru/model/flash/office/doc/images.pysimilarity index 95%rename from mineru/model/flash/doc/images.pyrename to mineru/model/flash/office/doc/images.pyindex 23ccf11e..f898f4fe 100644--- a/mineru/model/flash/doc/images.py+++ b/mineru/model/flash/office/doc/images.py@@ -9,16 +9,16 @@ import hashlibfrom loguru import logger-from mineru.model.flash.legacy_office import LegacyOfficeResourceLimitError-from mineru.model.flash.legacy_office.limits import MAX_ASSET_TOTAL_BYTES-from mineru.model.flash.legacy_office.officeart import (+from ..legacy import LegacyOfficeResourceLimitError+from ..legacy.limits import MAX_ASSET_TOTAL_BYTES+from ..legacy.officeart import (OfficeImagePayload,decode_bstore,extract_word_shapes,first_blip,record_at,)-from mineru.model.flash.office.image_equation import (+from ..image_equation import (OfficeImageEquationDecoder,)diff --git a/mineru/model/flash/doc/lists.py b/mineru/model/flash/office/doc/lists.pysimilarity index 100%rename from mineru/model/flash/doc/lists.pyrename to mineru/model/flash/office/doc/lists.pydiff --git a/mineru/model/flash/doc/models.py b/mineru/model/flash/office/doc/models.pysimilarity index 100%rename from mineru/model/flash/doc/models.pyrename to mineru/model/flash/office/doc/models.pydiff --git a/mineru/model/flash/doc/parser.py b/mineru/model/flash/office/doc/parser.pysimilarity index 99%rename from mineru/model/flash/doc/parser.pyrename to mineru/model/flash/office/doc/parser.pyindex 8d8cc7d0..0c520346 100644--- a/mineru/model/flash/doc/parser.py+++ b/mineru/model/flash/office/doc/parser.py@@ -7,7 +7,7 @@ from __future__ import annotationsfrom dataclasses import dataclass, fieldfrom loguru import logger-from mineru.model.flash.legacy_office import LegacyOfficeMalformedError+from ..legacy import LegacyOfficeMalformedErrorfrom .bookmarks import parse_bookmarksfrom .fib import (diff --git a/mineru/model/flash/doc/pieces.py b/mineru/model/flash/office/doc/pieces.pysimilarity index 99%rename from mineru/model/flash/doc/pieces.pyrename to mineru/model/flash/office/doc/pieces.pyindex 15d22b21..896377d5 100644--- a/mineru/model/flash/doc/pieces.py+++ b/mineru/model/flash/office/doc/pieces.py@@ -8,7 +8,7 @@ from bisect import bisect_leftfrom dataclasses import dataclassimport struct-from mineru.model.flash.legacy_office import LegacyOfficeMalformedError+from ..legacy import LegacyOfficeMalformedErrorfrom .records import DocBudget, bounded_slice, get_u16, get_u32diff --git a/mineru/model/flash/doc/records.py b/mineru/model/flash/office/doc/records.pysimilarity index 94%rename from mineru/model/flash/doc/records.pyrename to mineru/model/flash/office/doc/records.pyindex 4e87a3e5..69b5e153 100644--- a/mineru/model/flash/doc/records.py+++ b/mineru/model/flash/office/doc/records.py@@ -7,8 +7,8 @@ from __future__ import annotationsfrom dataclasses import dataclassimport struct-from mineru.model.flash.legacy_office import LegacyOfficeResourceLimitError-from mineru.model.flash.legacy_office.limits import MAX_RECORDS+from ..legacy import LegacyOfficeResourceLimitError+from ..legacy.limits import MAX_RECORDS@dataclass(slots=True)diff --git a/mineru/model/flash/doc/sprm.py b/mineru/model/flash/office/doc/sprm.pysimilarity index 100%rename from mineru/model/flash/doc/sprm.pyrename to mineru/model/flash/office/doc/sprm.pydiff --git a/mineru/model/flash/doc/styles.py b/mineru/model/flash/office/doc/styles.pysimilarity index 100%rename from mineru/model/flash/doc/styles.pyrename to mineru/model/flash/office/doc/styles.pydiff --git a/mineru/model/flash/docx/__init__.py b/mineru/model/flash/office/docx/__init__.pysimilarity index 77%rename from mineru/model/flash/docx/__init__.pyrename to mineru/model/flash/office/docx/__init__.pyindex e0a59fbf..c1c131ee 100644--- a/mineru/model/flash/docx/__init__.py+++ b/mineru/model/flash/office/docx/__init__.py@@ -1,3 +1,5 @@# Copyright (c) Opendatalab. All rights reserved."""Flash DOCX 转换实现。"""++__all__: list[str] = []diff --git a/mineru/model/flash/docx/docx_converter.py b/mineru/model/flash/office/docx/docx_converter.pysimilarity index 99%rename from mineru/model/flash/docx/docx_converter.pyrename to mineru/model/flash/office/docx/docx_converter.pyindex 68fa5236..0e1234e3 100644--- a/mineru/model/flash/docx/docx_converter.py+++ b/mineru/model/flash/office/docx/docx_converter.py@@ -18,25 +18,25 @@ from mammoth.conversion import convert_document_element_to_htmlfrom mammoth.docx import body_xmlfrom pydantic import AnyUrl-from mineru.model.flash.office.chart import extract_chart_html_from_ooxml-from mineru.model.flash.office.image import (+from ..chart import extract_chart_html_from_ooxml+from ..image import (serialize_office_image,)-from mineru.model.flash.office.ooxml_equation import (+from ..ooxml_equation import (OoxmlEquationDecoder,is_mathtype_equation_prog_id,)-from mineru.model.flash.office.image_equation import (+from ..image_equation import (OfficeImageEquationDecoder,)-from mineru.types import RAW_CAPTION-from mineru.model.flash.docx.equationxml import DocxEquationXmlDecoder-from mineru.model.flash.docx.package_normalizer import normalize_docx_package-from mineru.model.flash.docx.tools.math.omml import oMath2Latex-from mineru.model.flash.docx.tools.office_xml import read_str-from mineru.types import BlockType-from mineru.utils.docx_formatting import Formatting, Script-from mineru.utils.office_rich_text import (+from .....types import RAW_CAPTION+from .equationxml import DocxEquationXmlDecoder+from .package_normalizer import normalize_docx_package+from .tools.math.omml import oMath2Latex+from .tools.office_xml import read_str+from .....types import BlockType+from .formatting_types import Formatting, Script+from ..rich_text import (append_rich_text_element,build_text_mappings_from_elements,format_hyperlink_group,diff --git a/mineru/model/flash/docx/equationxml.py b/mineru/model/flash/office/docx/equationxml.pysimilarity index 95%rename from mineru/model/flash/docx/equationxml.pyrename to mineru/model/flash/office/docx/equationxml.pyindex aff249ae..afdc9b89 100644--- a/mineru/model/flash/docx/equationxml.py+++ b/mineru/model/flash/office/docx/equationxml.py@@ -9,11 +9,11 @@ import hashlibfrom lxml import etree # type: ignore[reportAttributeAccessIssue]-from mineru.model.flash.docx.tools.math.omml import oMath2Latex-from mineru.model.flash.legacy_office.errors import (+from .tools.math.omml import oMath2Latex+from ..legacy.errors import (LegacyOfficeResourceLimitError,)-from mineru.model.flash.legacy_office.limits import (+from ..legacy.limits import (MAX_ASSET_TOTAL_BYTES,MAX_ENTRY_BYTES,)diff --git a/mineru/utils/docx_formatting.py b/mineru/model/flash/office/docx/formatting_types.pysimilarity index 100%rename from mineru/utils/docx_formatting.pyrename to mineru/model/flash/office/docx/formatting_types.pydiff --git a/mineru/model/flash/docx/main.py b/mineru/model/flash/office/docx/main.pysimilarity index 97%rename from mineru/model/flash/docx/main.pyrename to mineru/model/flash/office/docx/main.pyindex 9fff99a4..b6024a81 100644--- a/mineru/model/flash/docx/main.py+++ b/mineru/model/flash/office/docx/main.py@@ -1,7 +1,7 @@# Copyright (c) Opendatalab. All rights reserved.from typing import Any, BinaryIO-from mineru.model.flash import DocxModel+from ... import DocxModeldef convert_path(file_path: str) -> list[list[dict[str, Any]]]:diff --git a/mineru/model/flash/docx/package_normalizer.py b/mineru/model/flash/office/docx/package_normalizer.pysimilarity index 100%rename from mineru/model/flash/docx/package_normalizer.pyrename to mineru/model/flash/office/docx/package_normalizer.pydiff --git a/mineru/model/flash/docx/tools/__init__.py b/mineru/model/flash/office/docx/tools/__init__.pysimilarity index 66%rename from mineru/model/flash/docx/tools/__init__.pyrename to mineru/model/flash/office/docx/tools/__init__.pyindex 1e17167c..818730ae 100644--- a/mineru/model/flash/docx/tools/__init__.py+++ b/mineru/model/flash/office/docx/tools/__init__.py@@ -1 +1,3 @@# Copyright (c) Opendatalab. All rights reserved.++__all__: list[str] = []diff --git a/mineru/model/flash/docx/tools/math/__init__.py b/mineru/model/flash/office/docx/tools/math/__init__.pysimilarity index 66%rename from mineru/model/flash/docx/tools/math/__init__.pyrename to mineru/model/flash/office/docx/tools/math/__init__.pyindex 1e17167c..818730ae 100644--- a/mineru/model/flash/docx/tools/math/__init__.py+++ b/mineru/model/flash/office/docx/tools/math/__init__.py@@ -1 +1,3 @@# Copyright (c) Opendatalab. All rights reserved.++__all__: list[str] = []diff --git a/mineru/model/flash/docx/tools/math/latex_dict.py b/mineru/model/flash/office/docx/tools/math/latex_dict.pysimilarity index 100%rename from mineru/model/flash/docx/tools/math/latex_dict.pyrename to mineru/model/flash/office/docx/tools/math/latex_dict.pydiff --git a/mineru/model/flash/docx/tools/math/omml.py b/mineru/model/flash/office/docx/tools/math/omml.pysimilarity index 100%rename from mineru/model/flash/docx/tools/math/omml.pyrename to mineru/model/flash/office/docx/tools/math/omml.pydiff --git a/mineru/model/flash/docx/tools/office_xml.py b/mineru/model/flash/office/docx/tools/office_xml.pysimilarity index 100%rename from mineru/model/flash/docx/tools/office_xml.pyrename to mineru/model/flash/office/docx/tools/office_xml.pydiff --git a/mineru/model/flash/office/image.py b/mineru/model/flash/office/image.pyindex 5f02fc75..2be0450e 100644--- a/mineru/model/flash/office/image.py+++ b/mineru/model/flash/office/image.py@@ -9,8 +9,8 @@ from typing import Finalfrom loguru import loggerfrom PIL import Image, ImageDraw, ImageFont, UnidentifiedImageError-from ....utils.check_sys_env import is_windows_environment-from ....utils.pdf_reader import image_to_b64str+from ....utils.platform import is_windows_environment+from ..pdf.raster import image_to_b64strVECTOR_IMAGE_FORMATS = frozenset({"WMF", "EMF"})VECTOR_IMAGE_EXTENSIONS = frozenset({".wmf", ".emf"})diff --git a/mineru/model/flash/office/image_equation.py b/mineru/model/flash/office/image_equation.pyindex 9424cec7..ae008852 100644--- a/mineru/model/flash/office/image_equation.py+++ b/mineru/model/flash/office/image_equation.py@@ -11,15 +11,15 @@ import structfrom loguru import logger-from mineru.model.flash.legacy_office.errors import (+from .legacy.errors import (LegacyOfficeResourceLimitError,)-from mineru.model.flash.legacy_office.limits import (+from .legacy.limits import (MAX_ASSET_TOTAL_BYTES,MAX_ENTRY_BYTES,MAX_PICTURE_RECORDS,)-from mineru.model.flash.legacy_office.mtef import decode_mtef+from .legacy.mtef import decode_mtef_PLACEABLE_WMF_MAGIC = b"\xd7\xcd\xc6\x9a"_META_ESCAPE = 0x0626diff --git a/mineru/model/flash/legacy_office/__init__.py b/mineru/model/flash/office/legacy/__init__.pysimilarity index 100%rename from mineru/model/flash/legacy_office/__init__.pyrename to mineru/model/flash/office/legacy/__init__.pydiff --git a/mineru/model/flash/legacy_office/errors.py b/mineru/model/flash/office/legacy/errors.pysimilarity index 100%rename from mineru/model/flash/legacy_office/errors.pyrename to mineru/model/flash/office/legacy/errors.pydiff --git a/mineru/model/flash/legacy_office/limits.py b/mineru/model/flash/office/legacy/limits.pysimilarity index 100%rename from mineru/model/flash/legacy_office/limits.pyrename to mineru/model/flash/office/legacy/limits.pydiff --git a/mineru/model/flash/legacy_office/mtef.py b/mineru/model/flash/office/legacy/mtef.pysimilarity index 100%rename from mineru/model/flash/legacy_office/mtef.pyrename to mineru/model/flash/office/legacy/mtef.pydiff --git a/mineru/model/flash/legacy_office/mtef_v5.py b/mineru/model/flash/office/legacy/mtef_v5.pysimilarity index 100%rename from mineru/model/flash/legacy_office/mtef_v5.pyrename to mineru/model/flash/office/legacy/mtef_v5.pydiff --git a/mineru/model/flash/legacy_office/officeart.py b/mineru/model/flash/office/legacy/officeart.pysimilarity index 100%rename from mineru/model/flash/legacy_office/officeart.pyrename to mineru/model/flash/office/legacy/officeart.pydiff --git a/mineru/model/flash/legacy_office/ole.py b/mineru/model/flash/office/legacy/ole.pysimilarity index 100%rename from mineru/model/flash/legacy_office/ole.pyrename to mineru/model/flash/office/legacy/ole.pydiff --git a/mineru/model/office_stream.py b/mineru/model/flash/office/legacy/stream.pysimilarity index 100%rename from mineru/model/office_stream.pyrename to mineru/model/flash/office/legacy/stream.pydiff --git a/mineru/model/flash/office/ooxml_equation.py b/mineru/model/flash/office/ooxml_equation.pyindex 34f9200c..26fcc9c4 100644--- a/mineru/model/flash/office/ooxml_equation.py+++ b/mineru/model/flash/office/ooxml_equation.py@@ -7,12 +7,12 @@ from __future__ import annotationsfrom dataclasses import dataclass, fieldimport hashlib-from mineru.model.flash.legacy_office.errors import LegacyOfficeResourceLimitError-from mineru.model.flash.legacy_office.limits import (+from .legacy.errors import LegacyOfficeResourceLimitError+from .legacy.limits import (MAX_ASSET_TOTAL_BYTES,MAX_ENTRY_BYTES,)-from mineru.model.flash.legacy_office.mtef import decode_equation_object+from .legacy.mtef import decode_equation_objectCFB_MAGIC = b"\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1"EQUATION_PROG_ID = "equation"diff --git a/mineru/model/flash/ppt/__init__.py b/mineru/model/flash/office/ppt/__init__.pysimilarity index 81%rename from mineru/model/flash/ppt/__init__.pyrename to mineru/model/flash/office/ppt/__init__.pyindex 40ec1201..333ac38b 100644--- a/mineru/model/flash/ppt/__init__.py+++ b/mineru/model/flash/office/ppt/__init__.py@@ -2,3 +2,4 @@"""PowerPoint 97–2003 二进制解析实现。"""+__all__: list[str] = []diff --git a/mineru/model/flash/ppt/models.py b/mineru/model/flash/office/ppt/models.pysimilarity index 100%rename from mineru/model/flash/ppt/models.pyrename to mineru/model/flash/office/ppt/models.pydiff --git a/mineru/model/flash/ppt/parser.py b/mineru/model/flash/office/ppt/parser.pysimilarity index 99%rename from mineru/model/flash/ppt/parser.pyrename to mineru/model/flash/office/ppt/parser.pyindex b105ed66..a476f73c 100644--- a/mineru/model/flash/ppt/parser.py+++ b/mineru/model/flash/office/ppt/parser.py@@ -13,27 +13,27 @@ import zlibfrom loguru import logger-from mineru.model.flash.legacy_office import (+from ..legacy import (BoundedOleReader,LegacyOfficeEncryptedError,LegacyOfficeMalformedError,LegacyOfficeResourceLimitError,)-from mineru.model.flash.legacy_office.limits import (+from ..legacy.limits import (MAX_ASSET_TOTAL_BYTES,MAX_ENTRY_BYTES,MAX_GRID_SLOTS,MAX_PICTURE_RECORDS,MAX_USER_EDIT_CHAIN,)-from mineru.model.flash.legacy_office.mtef import decode_equation_object-from mineru.model.flash.legacy_office.officeart import (+from ..legacy.mtef import decode_equation_object+from ..legacy.officeart import (OfficeArtRecord,OfficeImagePayload,decode_blip as decode_officeart_blip,)-from mineru.model.flash.office.image import serialize_office_image-from mineru.model.flash.office.image_equation import (+from ..image import serialize_office_image+from ..image_equation import (OfficeImageEquationDecoder,)from ..xls.embedded_chart import extract_embedded_chart_html_from_storagediff --git a/mineru/model/flash/ppt/ppt_converter.py b/mineru/model/flash/office/ppt/ppt_converter.pysimilarity index 97%rename from mineru/model/flash/ppt/ppt_converter.pyrename to mineru/model/flash/office/ppt/ppt_converter.pyindex 5a700ed9..60f327e4 100644--- a/mineru/model/flash/ppt/ppt_converter.py+++ b/mineru/model/flash/office/ppt/ppt_converter.py@@ -7,11 +7,11 @@ from __future__ import annotationsfrom html import escapefrom typing import Any, BinaryIO-from mineru.model.flash.legacy_office import BoundedOleReader-from mineru.model.flash.xycut import sort_entries-from mineru.model.office_stream import read_stream_bytes_from_start-from mineru.types import BlockType-from mineru.utils.office_rich_text import OfficeRichTextSegment, build_rich_text_from_segments+from ..legacy import BoundedOleReader+from ..._shared.xycut import sort_entries+from ..legacy.stream import read_stream_bytes_from_start+from .....types import BlockType+from ..rich_text import OfficeRichTextSegment, build_rich_text_from_segmentsfrom .models import (PptChartElement,diff --git a/mineru/model/flash/ppt/records.py b/mineru/model/flash/office/ppt/records.pysimilarity index 97%rename from mineru/model/flash/ppt/records.pyrename to mineru/model/flash/office/ppt/records.pyindex e68f12cd..82632e7e 100644--- a/mineru/model/flash/ppt/records.py+++ b/mineru/model/flash/office/ppt/records.py@@ -8,11 +8,11 @@ from dataclasses import dataclassimport structfrom typing import Iterator-from mineru.model.flash.legacy_office.errors import (+from ..legacy.errors import (LegacyOfficeMalformedError,LegacyOfficeResourceLimitError,)-from mineru.model.flash.legacy_office.limits import MAX_RECORD_DEPTH, MAX_RECORDS+from ..legacy.limits import MAX_RECORD_DEPTH, MAX_RECORDSCONTAINER_VERSION = 0xFROUNDTRIP_OPAQUE_MIN = 1053diff --git a/mineru/model/flash/ppt/style_text.py b/mineru/model/flash/office/ppt/style_text.pysimilarity index 100%rename from mineru/model/flash/ppt/style_text.pyrename to mineru/model/flash/office/ppt/style_text.pydiff --git a/mineru/model/flash/pptx/__init__.py b/mineru/model/flash/office/pptx/__init__.pysimilarity index 77%rename from mineru/model/flash/pptx/__init__.pyrename to mineru/model/flash/office/pptx/__init__.pyindex 23020b12..f38f86cb 100644--- a/mineru/model/flash/pptx/__init__.py+++ b/mineru/model/flash/office/pptx/__init__.py@@ -1,3 +1,5 @@# Copyright (c) Opendatalab. All rights reserved."""Flash PPTX 转换实现。"""++__all__: list[str] = []diff --git a/mineru/model/flash/pptx/main.py b/mineru/model/flash/office/pptx/main.pysimilarity index 93%rename from mineru/model/flash/pptx/main.pyrename to mineru/model/flash/office/pptx/main.pyindex 125c0405..a1edb789 100644--- a/mineru/model/flash/pptx/main.py+++ b/mineru/model/flash/office/pptx/main.py@@ -1,7 +1,7 @@# Copyright (c) Opendatalab. All rights reserved.from typing import Any, BinaryIO-from mineru.model.flash import PptxModel+from ... import PptxModeldef convert_path(file_path: str) -> list[list[dict[str, Any]]]:diff --git a/mineru/model/flash/pptx/package_normalizer.py b/mineru/model/flash/office/pptx/package_normalizer.pysimilarity index 100%rename from mineru/model/flash/pptx/package_normalizer.pyrename to mineru/model/flash/office/pptx/package_normalizer.pydiff --git a/mineru/model/flash/pptx/pptx_converter.py b/mineru/model/flash/office/pptx/pptx_converter.pysimilarity index 99%rename from mineru/model/flash/pptx/pptx_converter.pyrename to mineru/model/flash/office/pptx/pptx_converter.pyindex 7a0a58af..f3fca782 100644--- a/mineru/model/flash/pptx/pptx_converter.py+++ b/mineru/model/flash/office/pptx/pptx_converter.py@@ -12,22 +12,22 @@ from pptx import Presentation, presentationfrom pptx.enum.shapes import MSO_SHAPE_TYPE, PP_PLACEHOLDERfrom pptx.oxml.text import CT_TextLineBreak-from mineru.model.flash.office.chart import extract_chart_html_from_ooxml-from mineru.model.flash.office.image import PIL_IMAGE_LOAD_ERRORS, is_vector_image, serialize_vector_image_with_placeholder-from mineru.model.flash.office.image_equation import (+from ..chart import extract_chart_html_from_ooxml+from ..image import PIL_IMAGE_LOAD_ERRORS, is_vector_image, serialize_vector_image_with_placeholder+from ..image_equation import (OfficeImageEquationDecoder,)-from mineru.model.flash.office.ooxml_equation import (+from ..ooxml_equation import (OoxmlEquationDecoder,is_mathtype_equation_prog_id,)-from mineru.model.flash.docx.tools.math.omml import oMath2Latex-from mineru.model.office_stream import read_stream_bytes_from_start, rewind_stream-from mineru.model.flash.pptx.package_normalizer import normalize_pptx_package-from mineru.model.flash.xycut import sort_entries-from mineru.types import BlockType-from mineru.utils.office_rich_text import OfficeRichTextSegment, build_rich_text_from_segments-from mineru.utils.pdf_reader import image_to_b64str+from ..docx.tools.math.omml import oMath2Latex+from ..legacy.stream import read_stream_bytes_from_start, rewind_stream+from .package_normalizer import normalize_pptx_package+from ..._shared.xycut import sort_entries+from .....types import BlockType+from ..rich_text import OfficeRichTextSegment, build_rich_text_from_segments+from ...pdf.raster import image_to_b64strIGNORED_NOTES_PLACEHOLDER_TYPES: Final = {PP_PLACEHOLDER.SLIDE_IMAGE,diff --git a/mineru/utils/office_rich_text.py b/mineru/model/flash/office/rich_text.pysimilarity index 100%rename from mineru/utils/office_rich_text.pyrename to mineru/model/flash/office/rich_text.pydiff --git a/mineru/model/flash/xls/__init__.py b/mineru/model/flash/office/xls/__init__.pysimilarity index 79%rename from mineru/model/flash/xls/__init__.pyrename to mineru/model/flash/office/xls/__init__.pyindex f8de07d2..ff83e083 100644--- a/mineru/model/flash/xls/__init__.py+++ b/mineru/model/flash/office/xls/__init__.py@@ -1,3 +1,5 @@# Copyright (c) Opendatalab. All rights reserved."""Excel 97–2003 二进制解析实现。"""++__all__: list[str] = []diff --git a/mineru/model/flash/xls/chart.py b/mineru/model/flash/office/xls/chart.pysimilarity index 100%rename from mineru/model/flash/xls/chart.pyrename to mineru/model/flash/office/xls/chart.pydiff --git a/mineru/model/flash/xls/embedded_chart.py b/mineru/model/flash/office/xls/embedded_chart.pysimilarity index 98%rename from mineru/model/flash/xls/embedded_chart.pyrename to mineru/model/flash/office/xls/embedded_chart.pyindex 2c581009..f3a82497 100644--- a/mineru/model/flash/xls/embedded_chart.py+++ b/mineru/model/flash/office/xls/embedded_chart.py@@ -9,12 +9,12 @@ import structfrom loguru import logger-from ..legacy_office import BoundedOleReader-from ..legacy_office.errors import (+from ..legacy import BoundedOleReader+from ..legacy.errors import (LegacyOfficeMalformedError,LegacyOfficeResourceLimitError,)-from ..legacy_office.limits import MAX_GRID_SLOTS+from ..legacy.limits import MAX_GRID_SLOTSfrom .models import XlsCell, XlsRichText, XlsSheet, XlsWorkbookfrom .number_format import builtin_number_format, format_numberfrom .parser import parse_xls_workbookdiff --git a/mineru/model/flash/xls/models.py b/mineru/model/flash/office/xls/models.pysimilarity index 100%rename from mineru/model/flash/xls/models.pyrename to mineru/model/flash/office/xls/models.pydiff --git a/mineru/model/flash/xls/number_format.py b/mineru/model/flash/office/xls/number_format.pysimilarity index 100%rename from mineru/model/flash/xls/number_format.pyrename to mineru/model/flash/office/xls/number_format.pydiff --git a/mineru/model/flash/xls/parser.py b/mineru/model/flash/office/xls/parser.pysimilarity index 99%rename from mineru/model/flash/xls/parser.pyrename to mineru/model/flash/office/xls/parser.pyindex 6b26c874..df727e94 100644--- a/mineru/model/flash/xls/parser.py+++ b/mineru/model/flash/office/xls/parser.py@@ -11,18 +11,18 @@ import uuidfrom loguru import logger-from mineru.model.flash.legacy_office.errors import (+from ..legacy.errors import (LegacyOfficeEncryptedError,LegacyOfficeMalformedError,)-from mineru.model.flash.legacy_office.officeart import (+from ..legacy.officeart import (OfficeArtShape,OfficeImagePayload,decode_bstore,extract_excel_shapes,)-from mineru.model.flash.office.image import serialize_office_image-from mineru.model.flash.office.image_equation import (+from ..image import serialize_office_image+from ..image_equation import (OfficeImageEquationDecoder,)diff --git a/mineru/model/flash/xls/records.py b/mineru/model/flash/office/xls/records.pysimilarity index 97%rename from mineru/model/flash/xls/records.pyrename to mineru/model/flash/office/xls/records.pyindex a1161b83..3c784d20 100644--- a/mineru/model/flash/xls/records.py+++ b/mineru/model/flash/office/xls/records.py@@ -10,8 +10,8 @@ from typing import Iteratorfrom loguru import logger-from mineru.model.flash.legacy_office.errors import LegacyOfficeResourceLimitError-from mineru.model.flash.legacy_office.limits import MAX_RECORDS+from ..legacy.errors import LegacyOfficeResourceLimitError+from ..legacy.limits import MAX_RECORDSBOF = 0x0809EOF = 0x000Adiff --git a/mineru/model/flash/xls/strings.py b/mineru/model/flash/office/xls/strings.pysimilarity index 100%rename from mineru/model/flash/xls/strings.pyrename to mineru/model/flash/office/xls/strings.pydiff --git a/mineru/model/flash/xls/xls_converter.py b/mineru/model/flash/office/xls/xls_converter.pysimilarity index 96%rename from mineru/model/flash/xls/xls_converter.pyrename to mineru/model/flash/office/xls/xls_converter.pyindex dc802b41..0761a43a 100644--- a/mineru/model/flash/xls/xls_converter.py+++ b/mineru/model/flash/office/xls/xls_converter.py@@ -14,13 +14,13 @@ from openpyxl.cell.rich_text import CellRichText, TextBlock # type: ignore[repofrom openpyxl.cell.text import InlineFont # type: ignore[reportMissingModuleSource]from openpyxl.worksheet.worksheet import Worksheet # type: ignore[reportMissingModuleSource]-from mineru.model.flash.legacy_office import BoundedOleReader, LegacyOfficeEncryptedError-from mineru.model.flash.legacy_office.errors import LegacyOfficeResourceLimitError-from mineru.model.flash.legacy_office.limits import MAX_GRID_SLOTS-from mineru.model.flash.legacy_office.mtef import decode_equation_native-from mineru.model.flash.xlsx.xlsx_converter import ExcelTable, XlsxConverter-from mineru.model.office_stream import read_stream_bytes_from_start-from mineru.types import BlockType+from ..legacy import BoundedOleReader, LegacyOfficeEncryptedError+from ..legacy.errors import LegacyOfficeResourceLimitError+from ..legacy.limits import MAX_GRID_SLOTS+from ..legacy.mtef import decode_equation_native+from ..xlsx.xlsx_converter import ExcelTable, XlsxConverter+from ..legacy.stream import read_stream_bytes_from_start+from .....types import BlockTypefrom .models import XlsChart, XlsChartSheet, XlsRichText, XlsSheet, XlsWorkbookfrom .parser import parse_xls_workbookdiff --git a/mineru/model/flash/xlsx/__init__.py b/mineru/model/flash/office/xlsx/__init__.pysimilarity index 77%rename from mineru/model/flash/xlsx/__init__.pyrename to mineru/model/flash/office/xlsx/__init__.pyindex ab4748ff..61fac43a 100644--- a/mineru/model/flash/xlsx/__init__.py+++ b/mineru/model/flash/office/xlsx/__init__.py@@ -1,3 +1,5 @@# Copyright (c) Opendatalab. All rights reserved."""Flash XLSX 转换实现。"""++__all__: list[str] = []diff --git a/mineru/model/flash/xlsx/main.py b/mineru/model/flash/office/xlsx/main.pysimilarity index 93%rename from mineru/model/flash/xlsx/main.pyrename to mineru/model/flash/office/xlsx/main.pyindex 7efd1721..6938ee31 100644--- a/mineru/model/flash/xlsx/main.py+++ b/mineru/model/flash/office/xlsx/main.py@@ -1,7 +1,7 @@# Copyright (c) Opendatalab. All rights reserved.from typing import Any, BinaryIO-from mineru.model.flash import XlsxModel+from ... import XlsxModeldef convert_path(file_path: str) -> list[list[dict[str, Any]]]:diff --git a/mineru/model/flash/xlsx/ooxml_ole.py b/mineru/model/flash/office/xlsx/ooxml_ole.pysimilarity index 98%rename from mineru/model/flash/xlsx/ooxml_ole.pyrename to mineru/model/flash/office/xlsx/ooxml_ole.pyindex 6159bcd5..cf49743a 100644--- a/mineru/model/flash/xlsx/ooxml_ole.py+++ b/mineru/model/flash/office/xlsx/ooxml_ole.py@@ -12,13 +12,13 @@ import xml.etree.ElementTree as ETfrom loguru import logger-from mineru.model.flash.legacy_office.errors import LegacyOfficeResourceLimitError-from mineru.model.flash.legacy_office.limits import MAX_ENTRY_BYTES-from mineru.model.flash.office.image import serialize_office_image-from mineru.model.flash.office.image_equation import (+from ..legacy.errors import LegacyOfficeResourceLimitError+from ..legacy.limits import MAX_ENTRY_BYTES+from ..image import serialize_office_image+from ..image_equation import (OfficeImageEquationDecoder,)-from mineru.model.flash.office.ooxml_equation import (+from ..ooxml_equation import (OoxmlEquationDecoder,is_mathtype_equation_prog_id,)diff --git a/mineru/model/flash/xlsx/package_normalizer.py b/mineru/model/flash/office/xlsx/package_normalizer.pysimilarity index 100%rename from mineru/model/flash/xlsx/package_normalizer.pyrename to mineru/model/flash/office/xlsx/package_normalizer.pydiff --git a/mineru/model/flash/xlsx/xlsx_converter.py b/mineru/model/flash/office/xlsx/xlsx_converter.pysimilarity index 98%rename from mineru/model/flash/xlsx/xlsx_converter.pyrename to mineru/model/flash/office/xlsx/xlsx_converter.pyindex 49f431ed..3e144908 100644--- a/mineru/model/flash/xlsx/xlsx_converter.py+++ b/mineru/model/flash/office/xlsx/xlsx_converter.py@@ -20,29 +20,29 @@ from PIL import Imagefrom pydantic import BaseModel, Field, NonNegativeInt, PositiveIntfrom pydantic.dataclasses import dataclass-from mineru.model.flash.office.image import is_vector_image, serialize_vector_image_with_placeholder-from mineru.model.flash.office.image import serialize_office_image-from mineru.model.flash.office.image_equation import (+from ..image import is_vector_image, serialize_vector_image_with_placeholder+from ..image import serialize_office_image+from ..image_equation import (OfficeImageEquationDecoder,)-from mineru.model.flash.office.ooxml_equation import OoxmlEquationDecoder-from mineru.model.flash.legacy_office.errors import LegacyOfficeResourceLimitError-from mineru.model.flash.legacy_office.limits import MAX_ENTRY_BYTES-from mineru.model.flash.docx.tools.math.omml import oMath2Latex-from mineru.model.office_stream import read_stream_bytes_from_start, rewind_stream-from mineru.model.flash.xlsx.package_normalizer import (+from ..ooxml_equation import OoxmlEquationDecoder+from ..legacy.errors import LegacyOfficeResourceLimitError+from ..legacy.limits import MAX_ENTRY_BYTES+from ..docx.tools.math.omml import oMath2Latex+from ..legacy.stream import read_stream_bytes_from_start, rewind_stream+from .package_normalizer import (normalize_xlsx_package,strip_xlsx_ole_objects_for_openpyxl,)-from mineru.model.flash.xlsx.ooxml_ole import (+from .ooxml_ole import (XlsxOleEquationArtifact,package_has_sheet_ole_objects,read_sheet_image_artifacts,read_sheet_equation_artifacts,workbook_sheet_parts,)-from mineru.types import BlockType-from mineru.utils.pdf_reader import image_to_b64str+from .....types import BlockType+from ...pdf.raster import image_to_b64strAUTO_GAP_TOLERANCE_CANDIDATES = (0, 1, 2)AUTO_GAP_TOLERANCE_PREFERENCE = {1: 0, 0: 1, 2: 2}diff --git a/mineru/model/flash/native_pdf/__init__.py b/mineru/model/flash/pdf/__init__.pysimilarity index 80%rename from mineru/model/flash/native_pdf/__init__.pyrename to mineru/model/flash/pdf/__init__.pyindex 0fbfb83e..ce36d0cf 100644--- a/mineru/model/flash/native_pdf/__init__.py+++ b/mineru/model/flash/pdf/__init__.py@@ -1,3 +1,5 @@# Copyright (c) Opendatalab. All rights reserved."""Flash 原生 PDF 提取的内部实现包。"""++__all__: list[str] = []diff --git a/mineru/model/flash/native_pdf/auxiliary_text.py b/mineru/model/flash/pdf/auxiliary_text.pysimilarity index 99%rename from mineru/model/flash/native_pdf/auxiliary_text.pyrename to mineru/model/flash/pdf/auxiliary_text.pyindex ef482a4e..8694be2a 100644--- a/mineru/model/flash/native_pdf/auxiliary_text.py+++ b/mineru/model/flash/pdf/auxiliary_text.py@@ -11,7 +11,7 @@ from difflib import SequenceMatcherfrom typing import Literal-from mineru.types import BBox+from ....types import BBoxfrom .models import (_AxisLine,diff --git a/mineru/utils/pdf_classify.py b/mineru/model/flash/pdf/classify.pysimilarity index 99%rename from mineru/utils/pdf_classify.pyrename to mineru/model/flash/pdf/classify.pyindex 6bd918ae..603b0aa1 100644--- a/mineru/utils/pdf_classify.py+++ b/mineru/model/flash/pdf/classify.py@@ -13,7 +13,7 @@ from loguru import loggerfrom pypdf import PdfReaderfrom pypdf.generic import ContentStream-from .pdfium_guard import close_pdfium_child, pdfium_guard+from .pdfium import close_pdfium_child, pdfium_guardMAX_SAMPLE_PAGES = 10CHARS_THRESHOLD = 50@@ -1156,7 +1156,7 @@ def get_high_image_coverage_ratio_pdfium(pdf_doc: pdfium.PdfDocument, page_indicif __name__ == "__main__":- from .pdf_document import PDFDocument+ from .document import PDFDocumentwith open("/Users/myhloli/pdf/luanma2x10.pdf", "rb") as f:p_bytes = f.read()diff --git a/mineru/model/flash/native_pdf/code_blocks.py b/mineru/model/flash/pdf/code_blocks.pysimilarity index 99%rename from mineru/model/flash/native_pdf/code_blocks.pyrename to mineru/model/flash/pdf/code_blocks.pyindex 95f3a0c4..ce26995a 100644--- a/mineru/model/flash/native_pdf/code_blocks.py+++ b/mineru/model/flash/pdf/code_blocks.py@@ -9,9 +9,9 @@ import statisticsimport unicodedatafrom typing import Any-from mineru.utils.spatial_text import project_pdf_spatial_text-from mineru.types import BBox-from mineru.utils.pdf_document import PDFPathInfo+from .spatial_text import project_pdf_spatial_text+from ....types import BBox+from .document import PDFPathInfofrom .geometry import (_bbox_area,diff --git a/mineru/utils/draw_bbox.py b/mineru/model/flash/pdf/diagnostics.pysimilarity index 99%rename from mineru/utils/draw_bbox.pyrename to mineru/model/flash/pdf/diagnostics.pyindex 8b46d1ff..9de7f9a6 100644--- a/mineru/utils/draw_bbox.py+++ b/mineru/model/flash/pdf/diagnostics.py@@ -9,7 +9,7 @@ from loguru import loggerfrom pypdf import PageObject, PdfReader, PdfWriterfrom reportlab.pdfgen import canvas-from ..types import BBox, RAW_PHONETIC, Block, BlockType, ContentType, PageInfo, Span+from ....types import BBox, RAW_PHONETIC, Block, BlockType, ContentType, PageInfo, Span# 文本类 block 共用 text bbox 样式,避免新增文本形态时遗漏多个绘制入口。TEXT_LIKE_BLOCK_TYPES_FOR_BBOX = {@@ -448,7 +448,7 @@ if __name__ == "__main__":with open(json_path, "r", encoding="utf-8") as f:pdf_ann = json.load(f)pdf_info = pdf_ann["pdf_info"]- from mineru.utils.pdf_document import PDFDocument+ from .document import PDFDocumentdoc = PDFDocument(pdf_bytes)doc.draw_layout_bbox(pdf_info, "examples/output_with_layout.pdf")diff --git a/mineru/utils/pdf_document.py b/mineru/model/flash/pdf/document.pysimilarity index 99%rename from mineru/utils/pdf_document.pyrename to mineru/model/flash/pdf/document.pyindex 409007ac..90ffb4fe 100644--- a/mineru/utils/pdf_document.py+++ b/mineru/model/flash/pdf/document.py@@ -21,11 +21,11 @@ from pdftext.pdf.pages import assign_scripts, get_lines, get_spansfrom pdftext.schema import Bbox, Char, Linefrom PIL import Image, ImageOps-from ..types import BBox, PageInfo-from .pdf_classify import classify-from .pdf_image_tools import get_crop_img-from .pdf_reader import image_to_bytes-from .pdfium_guard import _pdfium_lock+from ....types import BBox, PageInfo+from ....utils.image import crop_pil_image+from .classify import classify+from .pdfium import _pdfium_lock+from .raster import image_to_byteslogger = logging.getLogger(__name__)@@ -358,7 +358,7 @@ class PDFDocument:image = self.render_page(page_idx, scale=scale)crop = Nonetry:- crop = get_crop_img(bbox, image.pil_image, scale=image.scale)+ crop = crop_pil_image(bbox, image.pil_image, scale=image.scale)return image_to_bytes(crop, image_format="JPEG")finally:if crop is not None:@@ -502,14 +502,14 @@ class PDFDocument:# ------------------------------------------------------------------ #def draw_layout_bbox(self, pages: list[PageInfo], output_path: str) -> None:- from .draw_bbox import draw_layout_bbox+ from .diagnostics import draw_layout_bboxout_dir = os.path.dirname(output_path) or "."filename = os.path.basename(output_path)draw_layout_bbox(pages, self._pdf_bytes, out_dir, filename)def draw_span_bbox(self, pages: list[PageInfo], output_path: str) -> None:- from .draw_bbox import draw_span_bbox+ from .diagnostics import draw_span_bboxout_dir = os.path.dirname(output_path) or "."filename = os.path.basename(output_path)diff --git a/mineru/model/flash/native_pdf/formulas.py b/mineru/model/flash/pdf/formulas.pysimilarity index 99%rename from mineru/model/flash/native_pdf/formulas.pyrename to mineru/model/flash/pdf/formulas.pyindex 6583dc22..6c03d908 100644--- a/mineru/model/flash/native_pdf/formulas.py+++ b/mineru/model/flash/pdf/formulas.py@@ -10,9 +10,9 @@ from dataclasses import dataclass, replacefrom typing import Any-from mineru.types import BBox-from mineru.utils.pdf_document import PDFPathInfo-from mineru.utils.text_utils import build_tagged_formula_content+from ....types import BBox+from .document import PDFPathInfo+from ....utils.text import build_tagged_formula_contentfrom .models import (_FormulaAnchor,diff --git a/mineru/model/flash/native_pdf/geometry.py b/mineru/model/flash/pdf/geometry.pysimilarity index 99%rename from mineru/model/flash/native_pdf/geometry.pyrename to mineru/model/flash/pdf/geometry.pyindex 4432029c..6cfda4d2 100644--- a/mineru/model/flash/native_pdf/geometry.py+++ b/mineru/model/flash/pdf/geometry.py@@ -8,7 +8,7 @@ import mathfrom typing import Any, Literal, Sequence-from mineru.types import BBox+from ....types import BBoxfrom .models import (_AxisLine,diff --git a/mineru/model/flash/native_pdf/graphics.py b/mineru/model/flash/pdf/graphics.pysimilarity index 99%rename from mineru/model/flash/native_pdf/graphics.pyrename to mineru/model/flash/pdf/graphics.pyindex 6f083d28..30d4ee03 100644--- a/mineru/model/flash/native_pdf/graphics.py+++ b/mineru/model/flash/pdf/graphics.py@@ -11,8 +11,8 @@ import statisticsfrom typing import Any-from mineru.types import BBox-from mineru.utils.pdf_document import PDFPathInfo+from ....types import BBox+from .document import PDFPathInfofrom .models import (_AxisLine,diff --git a/mineru/model/flash/native_pdf/index_blocks.py b/mineru/model/flash/pdf/index_blocks.pysimilarity index 99%rename from mineru/model/flash/native_pdf/index_blocks.pyrename to mineru/model/flash/pdf/index_blocks.pyindex c6cd494e..6a7e46ac 100644--- a/mineru/model/flash/native_pdf/index_blocks.py+++ b/mineru/model/flash/pdf/index_blocks.py@@ -10,7 +10,7 @@ import reimport statistics-from mineru.types import BBox, BlockType+from ....types import BBox, BlockTypefrom .models import _LineItemfrom .geometry import (diff --git a/mineru/model/flash/native_pdf/line_layout.py b/mineru/model/flash/pdf/line_layout.pysimilarity index 99%rename from mineru/model/flash/native_pdf/line_layout.pyrename to mineru/model/flash/pdf/line_layout.pyindex 6760d26a..15127358 100644--- a/mineru/model/flash/native_pdf/line_layout.py+++ b/mineru/model/flash/pdf/line_layout.py@@ -9,8 +9,8 @@ import reimport statistics-from mineru.utils.text_utils import is_hyphen_at_line_end-from mineru.types import BBox+from ....utils.text import is_hyphen_at_line_end+from ....types import BBoxfrom .models import (_LineItem,diff --git a/mineru/model/flash/native_pdf/line_merging.py b/mineru/model/flash/pdf/line_merging.pysimilarity index 99%rename from mineru/model/flash/native_pdf/line_merging.pyrename to mineru/model/flash/pdf/line_merging.pyindex e1d83289..5447501e 100644--- a/mineru/model/flash/native_pdf/line_merging.py+++ b/mineru/model/flash/pdf/line_merging.py@@ -7,7 +7,7 @@ from __future__ import annotationsimport statistics-from mineru.types import BBox+from ....types import BBoxfrom .models import (_LineItem,diff --git a/mineru/model/flash/native_pdf/models.py b/mineru/model/flash/pdf/models.pysimilarity index 98%rename from mineru/model/flash/native_pdf/models.pyrename to mineru/model/flash/pdf/models.pyindex dab80037..28c51f71 100644--- a/mineru/model/flash/native_pdf/models.py+++ b/mineru/model/flash/pdf/models.py@@ -9,8 +9,8 @@ from typing import Any, Literalfrom pdftext.schema import Char-from mineru.types import BBox-from mineru.utils.pdf_document import PDFPathInfo+from ....types import BBox+from .document import PDFPathInfo@dataclass(slots=True)diff --git a/mineru/model/flash/native_pdf/native_text.py b/mineru/model/flash/pdf/native_text.pysimilarity index 99%rename from mineru/model/flash/native_pdf/native_text.pyrename to mineru/model/flash/pdf/native_text.pyindex b3f334e8..004629e4 100644--- a/mineru/model/flash/native_pdf/native_text.py+++ b/mineru/model/flash/pdf/native_text.py@@ -11,8 +11,8 @@ from typing import Any, Literal, Sequencefrom pdftext.schema import Char-from mineru.types import BBox-from mineru.utils.pdf_document import PDFDocument+from ....types import BBox+from .document import PDFDocumentfrom .models import (_AxisLine,diff --git a/mineru/utils/pdfium_guard.py b/mineru/model/flash/pdf/pdfium.pysimilarity index 100%rename from mineru/utils/pdfium_guard.pyrename to mineru/model/flash/pdf/pdfium.pydiff --git a/mineru/model/flash/native_pdf/pipeline.py b/mineru/model/flash/pdf/pipeline.pysimilarity index 99%rename from mineru/model/flash/native_pdf/pipeline.pyrename to mineru/model/flash/pdf/pipeline.pyindex 785a291d..10a447d8 100644--- a/mineru/model/flash/native_pdf/pipeline.py+++ b/mineru/model/flash/pdf/pipeline.py@@ -8,9 +8,9 @@ from dataclasses import replacefrom typing import Any-from mineru.model.flash.xycut import sort_entries-from mineru.utils.pdf_document import PDFDocument, PDFImageInfo, get_lines_from_chars-from mineru.utils.pdf_text_styles import (+from .._shared.xycut import sort_entries+from .document import PDFDocument, PDFImageInfo, get_lines_from_chars+from .text_styles import (PDFTextLinkLine,PDFTextStyleLine,apply_pdf_text_links,diff --git a/mineru/utils/pdf_reader.py b/mineru/model/flash/pdf/raster.pysimilarity index 97%rename from mineru/utils/pdf_reader.pyrename to mineru/model/flash/pdf/raster.pyindex 1d9d6569..5c1256a3 100644--- a/mineru/utils/pdf_reader.py+++ b/mineru/model/flash/pdf/raster.py@@ -6,7 +6,7 @@ from loguru import loggerfrom PIL import Imagefrom pypdfium2 import PdfBitmap, PdfPage-from .pdfium_guard import pdfium_guard+from .pdfium import pdfium_guarddef page_to_image(diff --git a/mineru/utils/spatial_text.py b/mineru/model/flash/pdf/spatial_text.pysimilarity index 99%rename from mineru/utils/spatial_text.pyrename to mineru/model/flash/pdf/spatial_text.pyindex c63a9dbe..904824e6 100644--- a/mineru/utils/spatial_text.py+++ b/mineru/model/flash/pdf/spatial_text.py@@ -10,7 +10,7 @@ from typing import Anyimport numpy as npfrom pdftext.schema import Char-from mineru.types import BBox+from ....types import BBox# 空间投影思路参考 LiteParse v2.6.0 的字符分段和网格投影;diff --git a/mineru/utils/native_pdf_table/__init__.py b/mineru/model/flash/pdf/table_recovery/__init__.pysimilarity index 100%rename from mineru/utils/native_pdf_table/__init__.pyrename to mineru/model/flash/pdf/table_recovery/__init__.pydiff --git a/mineru/utils/native_pdf_table/candidate.py b/mineru/model/flash/pdf/table_recovery/candidate.pysimilarity index 99%rename from mineru/utils/native_pdf_table/candidate.pyrename to mineru/model/flash/pdf/table_recovery/candidate.pyindex 6f892037..02d08979 100644--- a/mineru/utils/native_pdf_table/candidate.py+++ b/mineru/model/flash/pdf/table_recovery/candidate.py@@ -7,7 +7,7 @@ import htmlfrom bisect import bisect_left, bisect_rightfrom dataclasses import dataclass-from mineru.types import BBox+from .....types import BBoxfrom .contracts import (NativeTableCandidate,diff --git a/mineru/utils/native_pdf_table/contracts.py b/mineru/model/flash/pdf/table_recovery/contracts.pysimilarity index 99%rename from mineru/utils/native_pdf_table/contracts.pyrename to mineru/model/flash/pdf/table_recovery/contracts.pyindex 2e5927a8..24853656 100644--- a/mineru/utils/native_pdf_table/contracts.py+++ b/mineru/model/flash/pdf/table_recovery/contracts.py@@ -8,7 +8,7 @@ from typing import Literalfrom pdftext.schema import Char-from mineru.types import BBox+from .....types import BBoxNativeTableCandidateSource = Literal["vector_grid",diff --git a/mineru/utils/native_pdf_table/engine.py b/mineru/model/flash/pdf/table_recovery/engine.pysimilarity index 100%rename from mineru/utils/native_pdf_table/engine.pyrename to mineru/model/flash/pdf/table_recovery/engine.pydiff --git a/mineru/utils/native_pdf_table/geometry.py b/mineru/model/flash/pdf/table_recovery/geometry.pysimilarity index 99%rename from mineru/utils/native_pdf_table/geometry.pyrename to mineru/model/flash/pdf/table_recovery/geometry.pyindex b3996d45..981371d0 100644--- a/mineru/utils/native_pdf_table/geometry.py+++ b/mineru/model/flash/pdf/table_recovery/geometry.py@@ -5,7 +5,7 @@ from __future__ import annotationsfrom collections.abc import Iterable-from mineru.types import BBox+from .....types import BBoxdef normalize_bbox(value: object) -> BBox | None:diff --git a/mineru/utils/native_pdf_table/sparse_hybrid.py b/mineru/model/flash/pdf/table_recovery/sparse_hybrid.pysimilarity index 100%rename from mineru/utils/native_pdf_table/sparse_hybrid.pyrename to mineru/model/flash/pdf/table_recovery/sparse_hybrid.pydiff --git a/mineru/utils/native_pdf_table/sparse_multiline.py b/mineru/model/flash/pdf/table_recovery/sparse_multiline.pysimilarity index 100%rename from mineru/utils/native_pdf_table/sparse_multiline.pyrename to mineru/model/flash/pdf/table_recovery/sparse_multiline.pydiff --git a/mineru/utils/native_pdf_table/text.py b/mineru/model/flash/pdf/table_recovery/text.pysimilarity index 99%rename from mineru/utils/native_pdf_table/text.pyrename to mineru/model/flash/pdf/table_recovery/text.pyindex 38c28e0e..53f2a9cb 100644--- a/mineru/utils/native_pdf_table/text.py+++ b/mineru/model/flash/pdf/table_recovery/text.py@@ -8,8 +8,8 @@ from dataclasses import dataclassfrom pdftext.schema import Char-from mineru.types import BBox-from mineru.utils.spatial_text import _normalize_table_text+from .....types import BBox+from ..spatial_text import _normalize_table_textfrom .contracts import (NativeTableGlyph,diff --git a/mineru/utils/native_pdf_table/text_grid.py b/mineru/model/flash/pdf/table_recovery/text_grid.pysimilarity index 100%rename from mineru/utils/native_pdf_table/text_grid.pyrename to mineru/model/flash/pdf/table_recovery/text_grid.pydiff --git a/mineru/utils/native_pdf_table/vector.py b/mineru/model/flash/pdf/table_recovery/vector.pysimilarity index 100%rename from mineru/utils/native_pdf_table/vector.pyrename to mineru/model/flash/pdf/table_recovery/vector.pydiff --git a/mineru/model/flash/native_pdf/tables.py b/mineru/model/flash/pdf/tables.pysimilarity index 99%rename from mineru/model/flash/native_pdf/tables.pyrename to mineru/model/flash/pdf/tables.pyindex 06bc5d88..8413f618 100644--- a/mineru/model/flash/native_pdf/tables.py+++ b/mineru/model/flash/pdf/tables.py@@ -12,7 +12,7 @@ from typing import Any, Literalfrom loguru import loggerfrom pdftext.schema import Char-from mineru.utils.native_pdf_table import (+from .table_recovery import (NativeTableInput,NativeTableRectangle,NativeTableRule,@@ -20,11 +20,11 @@ from mineru.utils.native_pdf_table import (coerce_native_table_rules,recover_native_pdf_table,)-from mineru.utils.text_utils import merge_text_line_contents-from mineru.utils.spatial_text import project_pdf_table_text-from mineru.types import BBox-from mineru.utils.pdf_document import PDFPathInfo-from mineru.utils.language import detect_lang+from ....utils.text import merge_text_line_contents+from .spatial_text import project_pdf_table_text+from ....types import BBox+from .document import PDFPathInfo+from ....utils.language import detect_langfrom .models import (_Fragment,diff --git a/mineru/model/flash/native_pdf/text_blocks.py b/mineru/model/flash/pdf/text_blocks.pysimilarity index 99%rename from mineru/model/flash/native_pdf/text_blocks.pyrename to mineru/model/flash/pdf/text_blocks.pyindex 56c46ffc..587f48db 100644--- a/mineru/model/flash/native_pdf/text_blocks.py+++ b/mineru/model/flash/pdf/text_blocks.py@@ -9,12 +9,12 @@ import statisticsfrom typing import Any, Sequence-from mineru.utils.text_utils import (+from ....utils.text import (is_hyphen_at_line_end,merge_text_line_contents,)-from mineru.types import BBox-from mineru.utils.language import detect_lang+from ....types import BBox+from ....utils.language import detect_langfrom .models import (_AxisLine,diff --git a/mineru/utils/pdf_text_styles.py b/mineru/model/flash/pdf/text_styles.pysimilarity index 99%rename from mineru/utils/pdf_text_styles.pyrename to mineru/model/flash/pdf/text_styles.pyindex faecb131..c15d9067 100644--- a/mineru/utils/pdf_text_styles.py+++ b/mineru/model/flash/pdf/text_styles.py@@ -12,9 +12,9 @@ from typing import Any, Iterable, Literal, Sequence, TypeVar, castfrom loguru import logger-from mineru.types import BBox, BlockType, RAW_CAPTION, RAW_FOOTNOTE-from mineru.utils.pdf_document import PDFLinkAnnotation-from mineru.utils.text_utils import is_hyphen_at_line_end+from ....types import BBox, BlockType, RAW_CAPTION, RAW_FOOTNOTE+from .document import PDFLinkAnnotation+from ....utils.text import is_hyphen_at_line_endTEXT_DECORATION_MIN_LENGTH_HEIGHT_RATIO = 1.8diff --git a/mineru/model/flash/native_pdf/titles.py b/mineru/model/flash/pdf/titles.pysimilarity index 99%rename from mineru/model/flash/native_pdf/titles.pyrename to mineru/model/flash/pdf/titles.pyindex 63629108..fa4e8e81 100644--- a/mineru/model/flash/native_pdf/titles.py+++ b/mineru/model/flash/pdf/titles.py@@ -9,8 +9,8 @@ from dataclasses import replacefrom typing import Literal-from mineru.types import BBox-from mineru.utils.pdf_text_styles import (+from ....types import BBox+from .text_styles import (PDF_FONT_FORCE_BOLD_FLAG,PDF_FONT_ITALIC_FLAG,)diff --git a/mineru/model/flash/native_pdf/visual_annotations.py b/mineru/model/flash/pdf/visual_annotations.pysimilarity index 99%rename from mineru/model/flash/native_pdf/visual_annotations.pyrename to mineru/model/flash/pdf/visual_annotations.pyindex 3ec2a1cb..8db8fdcf 100644--- a/mineru/model/flash/native_pdf/visual_annotations.py+++ b/mineru/model/flash/pdf/visual_annotations.py@@ -12,8 +12,8 @@ from dataclasses import dataclassfrom typing import Any, Literal-from mineru.model.flash.xycut import sort_entries-from mineru.types import BBox+from .._shared.xycut import sort_entries+from ....types import BBoxfrom .geometry import (_bbox_center_x,