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 synthetic PDF generation and corresponding tests for Flash and CJK layouts
myhloli4b181c6de2cc
diff --git "a/demo/pdfs/NPU_\345\274\200\345\217\221\347\216\257\345\242\203\351\203\250\347\275\262_\345\217\202\350\200\203\346\214\207\345\215\227.pdf" "b/demo/pdfs/NPU_\345\274\200\345\217\221\347\216\257\345\242\203\351\203\250\347\275\262_\345\217\202\350\200\203\346\214\207\345\215\227.pdf"deleted file mode 100644index 64ca6f1e..00000000Binary files "a/demo/pdfs/NPU_\345\274\200\345\217\221\347\216\257\345\242\203\351\203\250\347\275\262_\345\217\202\350\200\203\346\214\207\345\215\227.pdf" and /dev/null differdiff --git a/demo/pdfs/demo5.pdf b/demo/pdfs/demo5.pdfdeleted file mode 100644index 2ec21b15..00000000Binary files a/demo/pdfs/demo5.pdf and /dev/null differdiff --git a/tests/fixtures/generate_synthetic_pdf_fixtures.py b/tests/fixtures/generate_synthetic_pdf_fixtures.pynew file mode 100644index 00000000..88d7a126--- /dev/null+++ b/tests/fixtures/generate_synthetic_pdf_fixtures.py@@ -0,0 +1,465 @@+#!/usr/bin/env python3+"""生成不含真实文档内容的 Flash PDF 单元测试夹具。"""++from __future__ import annotations++import argparse+from io import BytesIO+from pathlib import Path+from tempfile import TemporaryDirectory++from PIL import Image+from reportlab.lib.colors import HexColor, black+from reportlab.lib.pagesizes import A4+from reportlab.lib.utils import ImageReader+from reportlab.pdfbase import cidfonts, pdfmetrics+from reportlab.pdfgen.canvas import Canvas+++PROJECT_ROOT = Path(__file__).resolve().parents[2]+OUTPUT_DIR = PROJECT_ROOT / "tests" / "unittest" / "pdfs"+FLASH_FIXTURE_NAME = "flash_table_annotations_synthetic.pdf"+CJK_FIXTURE_NAME = "native_cjk_layout_synthetic.pdf"+SAFE_WATERMARK_TEXT = "MINERU TEST WATERMARK"+NEUTRAL_METADATA_VALUE = "MinerU Test Suite"+CJK_FONT_NAME = "STSong-Light"+PAGE_WIDTH, PAGE_HEIGHT = A4+++def _register_fonts() -> None:+ """注册无需读取原文或本机私有字体文件的标准 CJK 字体。"""++ if CJK_FONT_NAME not in pdfmetrics.getRegisteredFontNames():+ pdfmetrics.registerFont(cidfonts.UnicodeCIDFont(CJK_FONT_NAME))+++def _new_canvas(output_path: Path) -> Canvas:+ """创建具有固定元数据和确定性对象编号的 A4 PDF 画布。"""++ canvas = Canvas(+ str(output_path),+ pagesize=A4,+ pageCompression=1,+ invariant=1,+ )+ canvas.setAuthor(NEUTRAL_METADATA_VALUE)+ canvas.setCreator(NEUTRAL_METADATA_VALUE)+ canvas.setTitle(NEUTRAL_METADATA_VALUE)+ canvas.setSubject("Synthetic PDF regression fixture")+ canvas.setKeywords("MinerU synthetic test fixture")+ canvas._doc.info.producer = NEUTRAL_METADATA_VALUE # noqa: SLF001+ return canvas+++def _draw_page_heading(canvas: Canvas, title: str, subtitle: str = "") -> None:+ """绘制统一的合成页面标题和可选副标题。"""++ canvas.setFillColor(black)+ canvas.setFont("Helvetica-Bold", 15)+ canvas.drawString(54, PAGE_HEIGHT - 54, title)+ if subtitle:+ canvas.setFont("Helvetica", 9)+ canvas.drawString(54, PAGE_HEIGHT - 70, subtitle)+++def _draw_page_number(canvas: Canvas, page_number: int) -> None:+ """在页面底部中央绘制独立页码。"""++ canvas.setFillColor(black)+ canvas.setFont("Helvetica", 9)+ canvas.drawCentredString(PAGE_WIDTH / 2, 30, str(page_number))+++def _draw_table(+ canvas: Canvas,+ *,+ left: float,+ top: float,+ width: float,+ row_height: float,+ rows: list[list[str]],+) -> tuple[float, float, float, float]:+ """用矢量线和中性单元格文本绘制稳定的规则表格。"""++ column_count = len(rows[0])+ height = row_height * len(rows)+ bottom = top - height+ column_width = width / column_count+ canvas.saveState()+ canvas.setStrokeColor(black)+ canvas.setLineWidth(0.8)+ for row_index in range(len(rows) + 1):+ y = top - row_index * row_height+ canvas.line(left, y, left + width, y)+ for column_index in range(column_count + 1):+ x = left + column_index * column_width+ canvas.line(x, bottom, x, top)+ canvas.setFont("Helvetica", 8)+ for row_index, row in enumerate(rows):+ baseline = top - row_index * row_height - 0.68 * row_height+ for column_index, value in enumerate(row):+ canvas.drawString(left + column_index * column_width + 5, baseline, value)+ canvas.restoreState()+ return left, bottom, left + width, top+++def _solid_image_reader(color: tuple[int, int, int]) -> ImageReader:+ """创建仅用于图像和 footer 几何回归的内存 PNG。"""++ image = Image.new("RGB", (80, 50), color=color)+ buffer = BytesIO()+ image.save(buffer, format="PNG", optimize=False)+ buffer.seek(0)+ return ImageReader(buffer)+++def _draw_flash_fixture(output_path: Path) -> None:+ """生成八页表格、注释、跨页和 footer 行为合成夹具。"""++ canvas = _new_canvas(output_path)++ _draw_page_heading(canvas, "Synthetic Flash Table Fixture", "Neutral content for parser regression tests")+ canvas.setFont("Helvetica", 11)+ canvas.drawString(72, 690, "This document contains only generated test content.")+ canvas.drawString(72, 668, "Each page isolates one layout behavior used by the test suite.")+ _draw_page_number(canvas, 1)+ canvas.showPage()++ _draw_page_heading(canvas, "Two Independent Vector Tables")+ canvas.setFont("Helvetica-Bold", 10)+ canvas.drawString(72, 715, "Table 1 Synthetic Inventory")+ _draw_table(+ canvas,+ left=72,+ top=700,+ width=450,+ row_height=28,+ rows=[+ ["ITEM", "VALUE", "STATE"],+ ["ALPHA", "10", "READY"],+ ["BETA", "20", "READY"],+ ["GAMMA", "30", "DONE"],+ ],+ )+ canvas.drawString(72, 545, "Table 2 Synthetic Metrics")+ _draw_table(+ canvas,+ left=72,+ top=530,+ width=450,+ row_height=28,+ rows=[+ ["METRIC", "LOW", "HIGH"],+ ["WIDTH", "12", "48"],+ ["HEIGHT", "8", "32"],+ ["COUNT", "3", "9"],+ ],+ )+ canvas.setFont("Helvetica", 10)+ canvas.drawString(72, 370, "Ordinary text below both tables must remain outside table bodies.")+ _draw_page_number(canvas, 2)+ canvas.showPage()++ _draw_page_heading(canvas, "Same-page Table Footnote Continuation")+ canvas.setFont("Helvetica-Bold", 10)+ canvas.drawString(72, 715, "Table 3 Synthetic Footnote Merge")+ _draw_table(+ canvas,+ left=72,+ top=700,+ width=450,+ row_height=30,+ rows=[+ ["FIELD", "DETAIL", "STATUS"],+ ["A", "Generated value", "OK"],+ ["B", "Generated value", "OK"],+ ["C", "Generated value", "OK"],+ ],+ )+ canvas.setFont("Helvetica", 8)+ canvas.drawString(76, 535, "Note: This generated note belongs to Table 3.")+ canvas.drawString(92, 523, "Its first indented continuation remains on the same page.")+ canvas.drawString(92, 511, "Its second indented continuation completes the annotation.")+ _draw_page_number(canvas, 3)+ canvas.showPage()++ _draw_page_heading(canvas, "In-border Note Remains Table Content")+ canvas.setFont("Helvetica-Bold", 10)+ canvas.drawString(72, 715, "Table 4 Bordered Note")+ _draw_table(+ canvas,+ left=72,+ top=700,+ width=450,+ row_height=34,+ rows=[+ ["KEY", "DESCRIPTION", "FLAG"],+ ["A1", "Neutral row", "YES"],+ ["A2", "Neutral row", "NO"],+ ["NOTE", "Note: This sentence is inside the border.", "TABLE"],+ ],+ )+ _draw_page_number(canvas, 4)+ canvas.showPage()++ _draw_page_heading(canvas, "Body Text Negative Samples")+ canvas.setFont("Helvetica", 10)+ canvas.drawString(72, 700, "This ordinary paragraph is unrelated to any table or figure.")+ canvas.drawString(72, 680, "ITEM_001 and VALUE_002 are prose tokens, not a code block.")+ canvas.drawString(72, 660, "A distant Note: marker remains body text without a visual parent.")+ canvas.drawString(72, 620, "The parser should preserve these lines as readable text.")+ _draw_page_number(canvas, 5)+ canvas.showPage()++ _draw_page_heading(canvas, "Code-like Cells Stay in a Table")+ canvas.setFont("Helvetica-Bold", 10)+ canvas.drawString(72, 715, "Table 5 Generated Token Grid")+ _draw_table(+ canvas,+ left=72,+ top=700,+ width=450,+ row_height=30,+ rows=[+ ["TOKEN", "EXPRESSION", "RESULT"],+ ["ROW_001", "A=B+1", "PASS"],+ ["ROW_002", "C=D+2", "PASS"],+ ["ROW_003", "E=F+3", "PASS"],+ ],+ )+ canvas.setFont("Helvetica", 8)+ canvas.drawString(76, 566, "Note: Token-shaped cell text must not become a code block.")+ _draw_page_number(canvas, 6)+ canvas.showPage()++ _draw_page_heading(canvas, "Cross-page Footnote Boundary")+ canvas.setFont("Helvetica-Bold", 10)+ canvas.drawString(72, 250, "Table 6 Page-local Annotation")+ _draw_table(+ canvas,+ left=72,+ top=235,+ width=450,+ row_height=30,+ rows=[+ ["GROUP", "VALUE", "STATE"],+ ["LOCAL", "77", "OPEN"],+ ["LOCAL", "88", "CLOSED"],+ ],+ )+ canvas.setFont("Helvetica", 8)+ canvas.drawString(76, 132, "Note: This annotation ends on page seven.")+ _draw_page_number(canvas, 7)+ canvas.showPage()++ _draw_page_heading(canvas, "Cross-page Text and Empty Footer Image")+ canvas.setFont("Helvetica", 9)+ canvas.drawString(92, 744, "This top paragraph must not merge into the previous page footnote.")+ canvas.drawString(72, 700, "The final page also contains an image below its page number.")+ _draw_page_number(canvas, 8)+ canvas.drawImage(+ _solid_image_reader((220, 230, 240)),+ PAGE_WIDTH / 2 - 60,+ 1,+ width=120,+ height=26,+ mask="auto",+ )+ canvas.showPage()+ canvas.save()+++def _draw_safe_watermark_grid(canvas: Canvas) -> None:+ """在当前页底层绘制四乘四个安全旋转文本水印。"""++ canvas.saveState()+ canvas.setFillColor(HexColor("#D9DEE7"))+ canvas.setFont("Helvetica", 7)+ for row_index in range(4):+ for column_index in range(4):+ canvas.saveState()+ canvas.translate(48 + column_index * 145, 120 + row_index * 185)+ canvas.rotate(5.5)+ canvas.drawString(0, 0, SAFE_WATERMARK_TEXT)+ canvas.restoreState()+ canvas.restoreState()+++def _draw_cjk_page_heading(canvas: Canvas, title: str) -> None:+ """用标准 CJK 字体绘制合成中文页面标题。"""++ canvas.setFillColor(black)+ canvas.setFont(CJK_FONT_NAME, 15)+ canvas.drawString(54, PAGE_HEIGHT - 54, title)+++def _draw_mixed_line(+ canvas: Canvas,+ *,+ y: float,+ cjk_prefix: str,+ latin_suffix: str,+) -> None:+ """在同一基线绘制 CJK 与西文字体混排的物理行。"""++ line_x = 72.0+ if cjk_prefix.startswith("• "):+ canvas.setFont("Helvetica", 10)+ canvas.drawString(line_x, y, "• ")+ line_x += pdfmetrics.stringWidth("• ", "Helvetica", 10)+ cjk_prefix = cjk_prefix[2:]+ canvas.setFont(CJK_FONT_NAME, 10)+ canvas.drawString(line_x, y, cjk_prefix)+ prefix_width = pdfmetrics.stringWidth(cjk_prefix, CJK_FONT_NAME, 10)+ canvas.setFont("Helvetica", 10)+ canvas.drawString(line_x + prefix_width, y, latin_suffix)+++def _draw_link_text(+ canvas: Canvas,+ *,+ x: float,+ y: float,+ visible_text: str,+ target: str,+) -> float:+ """绘制带精确 URI 注解的西文文本并返回其右边界。"""++ font_name = "Helvetica"+ font_size = 9+ width = pdfmetrics.stringWidth(visible_text, font_name, font_size)+ canvas.setFont(font_name, font_size)+ canvas.drawString(x, y, visible_text)+ canvas.linkURL(+ target,+ (x, y - 2, x + width, y + font_size + 1),+ relative=0,+ thickness=0,+ )+ return x + width+++def _draw_cjk_fixture(output_path: Path) -> None:+ """生成四页目录、字体、URL 和安全水印合成夹具。"""++ _register_fonts()+ canvas = _new_canvas(output_path)++ _draw_safe_watermark_grid(canvas)+ _draw_cjk_page_heading(canvas, "MinerU 合成原生文本测试")+ canvas.setFont(CJK_FONT_NAME, 11)+ canvas.drawString(72, 690, "本文档完全由测试生成器创建,不包含真实人员或组织信息。")+ canvas.drawString(72, 665, "页面用于验证目录、图注、链接、字体基线和水印过滤。")+ _draw_page_number(canvas, 1)+ canvas.showPage()++ _draw_safe_watermark_grid(canvas)+ _draw_cjk_page_heading(canvas, "目录")+ canvas.setFont(CJK_FONT_NAME, 9)+ for row_index in range(24):+ baseline = 742 - row_index * 26+ canvas.drawString(65, baseline, f"{row_index + 1} 合成章节 {row_index + 1}")+ canvas.drawRightString(520, baseline, str(row_index + 1))+ _draw_page_number(canvas, 2)+ canvas.showPage()++ _draw_safe_watermark_grid(canvas)+ _draw_cjk_page_heading(canvas, "混合字体和基线")+ _draw_mixed_line(canvas, y=700, cjk_prefix="• 合成支持工程师 ", latin_suffix="Support Engineer")+ _draw_mixed_line(canvas, y=660, cjk_prefix="• 混合字体工具 ", latin_suffix="Acuity Toolkit")+ _draw_mixed_line(canvas, y=620, cjk_prefix="• 测试系统 ", latin_suffix="Ubuntu 24.04")+ canvas.setFont("Helvetica", 10)+ canvas.drawString(72, 580, "mineru_toolkit_binary_1.0.0_linux_x86_64.tgz")+ canvas.setFont(CJK_FONT_NAME, 10)+ canvas.drawString(72, 535, "以上普通文本均应保持在基线,不应生成上下标标签。")+ _draw_page_number(canvas, 3)+ canvas.showPage()++ _draw_safe_watermark_grid(canvas)+ _draw_cjk_page_heading(canvas, "图注和链接")+ canvas.drawImage(_solid_image_reader((210, 225, 240)), 72, 565, width=190, height=105, mask="auto")+ canvas.drawImage(_solid_image_reader((235, 220, 210)), 332, 565, width=190, height=105, mask="auto")+ canvas.setFont(CJK_FONT_NAME, 9)+ canvas.drawString(72, 548, "图 1 合成示意图 A")+ canvas.drawString(332, 548, "图 2 合成示意图 B")+ wrapped_url = "https://example.com/downloads/mineru/fixture/"+ _draw_link_text(+ canvas,+ x=72,+ y=485,+ visible_text="https://example.com/downloads/",+ target=wrapped_url,+ )+ _draw_link_text(+ canvas,+ x=72,+ y=473,+ visible_text="mineru/fixture/",+ target=wrapped_url,+ )+ link_x = 72.0+ for link_index, target in enumerate(+ (+ "https://example.com/ref/a",+ "https://example.com/ref/b",+ "https://example.com/ref/c",+ )+ ):+ if link_index:+ link_x += pdfmetrics.stringWidth(" ", "Helvetica", 9)+ link_x = _draw_link_text(+ canvas,+ x=link_x,+ y=425,+ visible_text=target,+ target=target,+ )+ canvas.setFont(CJK_FONT_NAME, 9)+ canvas.drawString(72, 390, "链接均使用保留域名,不指向真实账号或资源。")+ _draw_page_number(canvas, 4)+ canvas.showPage()+ canvas.save()+++def generate_fixtures(output_dir: Path) -> tuple[Path, Path]:+ """生成两份合成 PDF 并返回稳定输出路径。"""++ output_dir.mkdir(parents=True, exist_ok=True)+ flash_path = output_dir / FLASH_FIXTURE_NAME+ cjk_path = output_dir / CJK_FIXTURE_NAME+ _draw_flash_fixture(flash_path)+ _draw_cjk_fixture(cjk_path)+ return flash_path, cjk_path+++def _check_committed_fixtures() -> None:+ """重新生成夹具并逐字节校验仓库产物未发生漂移。"""++ with TemporaryDirectory(prefix="mineru-synthetic-pdf-") as temporary_directory:+ generated_paths = generate_fixtures(Path(temporary_directory))+ for generated_path in generated_paths:+ committed_path = OUTPUT_DIR / generated_path.name+ if not committed_path.is_file():+ raise SystemExit(f"missing committed fixture: {committed_path}")+ if generated_path.read_bytes() != committed_path.read_bytes():+ raise SystemExit(f"fixture is stale: {committed_path}")+++def main() -> None:+ """解析命令行参数并执行生成或一致性检查。"""++ parser = argparse.ArgumentParser(description=__doc__)+ parser.add_argument(+ "--check",+ action="store_true",+ help="regenerate in a temporary directory and compare committed PDFs",+ )+ arguments = parser.parse_args()+ if arguments.check:+ _check_committed_fixtures()+ return+ generate_fixtures(OUTPUT_DIR)+++if __name__ == "__main__":+ main()diff --git a/tests/unittest/pdfs/flash_table_annotations_synthetic.pdf b/tests/unittest/pdfs/flash_table_annotations_synthetic.pdfnew file mode 100644index 00000000..72ea1bf5--- /dev/null+++ b/tests/unittest/pdfs/flash_table_annotations_synthetic.pdf@@ -0,0 +1,218 @@+%PDF-1.4+%���� ReportLab Generated PDF document http://www.reportlab.com+1 0 obj+<<+/F1 2 0 R /F2 3 0 R+>>+endobj+2 0 obj+<<+/BaseFont /Helvetica /Encoding /WinAnsiEncoding /Name /F1 /Subtype /Type1 /Type /Font+>>+endobj+3 0 obj+<<+/BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding /Name /F2 /Subtype /Type1 /Type /Font+>>+endobj+4 0 obj+<<+/Contents 16 0 R /MediaBox [ 0 0 595.2756 841.8898 ] /Parent 15 0 R /Resources <<+/Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]+>> /Rotate 0 /Trans <<++>>+ /Type /Page+>>+endobj+5 0 obj+<<+/Contents 17 0 R /MediaBox [ 0 0 595.2756 841.8898 ] /Parent 15 0 R /Resources <<+/Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]+>> /Rotate 0 /Trans <<++>>+ /Type /Page+>>+endobj+6 0 obj+<<+/Contents 18 0 R /MediaBox [ 0 0 595.2756 841.8898 ] /Parent 15 0 R /Resources <<+/Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]+>> /Rotate 0 /Trans <<++>>+ /Type /Page+>>+endobj+7 0 obj+<<+/Contents 19 0 R /MediaBox [ 0 0 595.2756 841.8898 ] /Parent 15 0 R /Resources <<+/Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]+>> /Rotate 0 /Trans <<++>>+ /Type /Page+>>+endobj+8 0 obj+<<+/Contents 20 0 R /MediaBox [ 0 0 595.2756 841.8898 ] /Parent 15 0 R /Resources <<+/Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]+>> /Rotate 0 /Trans <<++>>+ /Type /Page+>>+endobj+9 0 obj+<<+/Contents 21 0 R /MediaBox [ 0 0 595.2756 841.8898 ] /Parent 15 0 R /Resources <<+/Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]+>> /Rotate 0 /Trans <<++>>+ /Type /Page+>>+endobj+10 0 obj+<<+/Contents 22 0 R /MediaBox [ 0 0 595.2756 841.8898 ] /Parent 15 0 R /Resources <<+/Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]+>> /Rotate 0 /Trans <<++>>+ /Type /Page+>>+endobj+11 0 obj+<<+/BitsPerComponent 8 /ColorSpace /DeviceRGB /Filter [ /ASCII85Decode /FlateDecode ] /Height 50 /Length 52 /Subtype /Image+ /Type /XObject /Width 80+>>+stream+Gb"0<0b"*_$j.XP*ddXaKZVjK+^J&I<E3%!<E3%!<V?4iCK2Ic~>endstream+endobj+12 0 obj+<<+/Contents 23 0 R /MediaBox [ 0 0 595.2756 841.8898 ] /Parent 15 0 R /Resources <<+/Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ] /XObject <<+/FormXob.95340d3e485331727775aa13da4b0f71 11 0 R+>>+>> /Rotate 0 /Trans <<++>>+ /Type /Page+>>+endobj+13 0 obj+<<+/PageMode /UseNone /Pages 15 0 R /Type /Catalog+>>+endobj+14 0 obj+<<+/Author (MinerU Test Suite) /CreationDate (D:20000101000000+00'00') /Creator (MinerU Test Suite) /Keywords (MinerU synthetic test fixture) /ModDate (D:20000101000000+00'00') /Producer (MinerU Test Suite)+ /Subject (Synthetic PDF regression fixture) /Title (MinerU Test Suite) /Trapped /False+>>+endobj+15 0 obj+<<+/Count 8 /Kids [ 4 0 R 5 0 R 6 0 R 7 0 R 8 0 R 9 0 R 10 0 R 12 0 R ] /Type /Pages+>>+endobj+16 0 obj+<<+/Filter [ /ASCII85Decode /FlateDecode ] /Length 341+>>+stream+Gas2EbAMqd&4Q?hMS!]:TU86"D5FJ:\uC1pO9mlJ]<Y.2rk?BKPpgBYaU?GYS3(58fH1msFp),2SneOrJ7$*t-j+t<M'(a(@Ceg>8AOfC:i9kEau3.hTdYht/1Y'InaJ^mf9;CMl9X&D>VlPVQ="MboE]mLJ(bHl\I.+OqL`%W?h,.1cA2M'<fWE^72pU[A')M_B?48U'c^@hmlcU5;&UbTU*@FYMM$QUdc.@_Bj;()8P!EdeM*aC77K6t#KKW!kgm.S*nT0pdIob;8!$a^*jG,>K:)>mcqlAZV&s9ST%qQZgKOi)P)f82gJ@WhG=e&i/Bph`lWe7]_;Q=cPDWE~>endstream+endobj+17 0 obj+<<+/Filter [ /ASCII85Decode /FlateDecode ] /Length 709+>>+stream+GasbY?^$p4'ZJu.'_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lS$Gp3Eo=0dsd,<O2M8Km\ZgWuSLMUODC;0;kJed?ZP5a\qac<MmI2==+o;>T"pd9p$BdT@IT#`g/4GA*)F_A_;U^j!qsZP+>'c%%6Tg5-.Mbf>ug:bY;kFCRMUTh$/(-4JSd#X]N8+*6Rg=re5MTW;9eJh9U<]0;e,SCQ;:+Hk)l>GStU-NcQ)Z%T%.5e6E[uK;^m-"EN?>H_TM639a1Lf;:I!&HAOae1cdCiM/\&?."-D`23>'M)sT+ODgU$8TQADk,T-[W<]+j^XLsr'&)A7i9Mh2ljNDRI:a.Z$+S#a0T1VW#CW<"EW~>endstream+endobj+23 0 obj+<<+/Filter [ /ASCII85Decode /FlateDecode ] /Length 376+>>+stream+Gas2D9hPRC(khAT/*<d^l/o%g?I]eo01$.TZYeE6Bf9aiqXO#K[k"g.'$)4Pml^2rU+V4]pW<RK#.#TZAM>'"5m5C>(8e*%8)..?JUttkTI7:_dO@`p.'8<V9bBO+*b.b*I^!#]j1[9b^W+,$q&@KgZAWu$7D"9,_q[shV[CZSW6$-;L-Z,#VOLkXOMcUb7_=Y'fYJY.7NXCuMZqi-3?[c1L?Lh4E(h+\C^RhB*4[Er,#gkXon4a]Y.'2XTKT*$<TpdVqGamhGNt7?*Ps284N7%bhn"%MIf4p!m`-5;.$kkMgd#5b]N:>gUY$QF.l-9[Q^O,BB$1ba>A-SQ\Z"-8#q\08MCGBt[?RksB^:YPGRDu:L$AonH%eZ~>endstream+endobj+xref+0 24+0000000000 65535 f+0000000073 00000 n+0000000114 00000 n+0000000221 00000 n+0000000333 00000 n+0000000538 00000 n+0000000743 00000 n+0000000948 00000 n+0000001153 00000 n+0000001358 00000 n+0000001563 00000 n+0000001769 00000 n+0000002009 00000 n+0000002279 00000 n+0000002349 00000 n+0000002665 00000 n+0000002769 00000 n+0000003201 00000 n+0000004001 00000 n+0000004661 00000 n+0000005231 00000 n+0000005737 00000 n+0000006350 00000 n+0000006890 00000 n+trailer+<<+/ID+[<b0ce4bb64c905e47caef5c06c690f477><b0ce4bb64c905e47caef5c06c690f477>]+% ReportLab generated PDF document -- digest (http://www.reportlab.com)++/Info 14 0 R+/Root 13 0 R+/Size 24+>>+startxref+7357+%%EOFdiff --git a/tests/unittest/pdfs/native_cjk_layout_synthetic.pdf b/tests/unittest/pdfs/native_cjk_layout_synthetic.pdfnew file mode 100644index 00000000..439d65a8--- /dev/null+++ b/tests/unittest/pdfs/native_cjk_layout_synthetic.pdf@@ -0,0 +1,206 @@+%PDF-1.4+%���� ReportLab Generated PDF document http://www.reportlab.com+1 0 obj+<<+/F1 2 0 R /F2 3 0 R+>>+endobj+2 0 obj+<<+/BaseFont /Helvetica /Encoding /WinAnsiEncoding /Name /F1 /Subtype /Type1 /Type /Font+>>+endobj+3 0 obj+<<+/BaseFont /STSong-Light /DescendantFonts [ <<+/BaseFont /STSong-Light /CIDSystemInfo <<+/Ordering (GB1) /Registry (Adobe) /Supplement 0+>> /DW 1000 /FontDescriptor <<+/Ascent 752 /CapHeight 737 /Descent -271 /Flags 6 /FontBBox [ -25 -254 1000 880 ] /FontName /STSongStd-Light+ /ItalicAngle 0 /Leading 148 /MaxWidth 1000 /MissingWidth 500 /StemH 91 /StemV 58+ /Type /FontDescriptor /XHeight 553+>> /Subtype /CIDFontType0 /Type /Font+ /W [ 1 [ 207 270 342 467 462 797 710 239 374 ] 10 [ 374 423 605 238 375 238 334 462 ] 18 26 462 27 28 238+ 29 31 605 32 [ 344 748 684 560 695 739 563 511 729 793+ 318 312 666 526 896 758 772 544 772 628+ 465 607 753 711 972 647 620 607 374 333+ 374 606 500 239 417 503 427 529 415 264+ 444 518 241 230 495 228 793 527 524 ] 81 [ 524 504 338 336 277 517 450 652 466 452+ 407 370 258 370 605 ] ]+>> ] /Encoding /UniGB-UCS2-H /Name /F2 /Subtype /Type0 /Type /Font+>>+endobj+4 0 obj+<<+/Contents 18 0 R /MediaBox [ 0 0 595.2756 841.8898 ] /Parent 17 0 R /Resources <<+/Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]+>> /Rotate 0 /Trans <<++>>+ /Type /Page+>>+endobj+5 0 obj+<<+/Contents 19 0 R /MediaBox [ 0 0 595.2756 841.8898 ] /Parent 17 0 R /Resources <<+/Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]+>> /Rotate 0 /Trans <<++>>+ /Type /Page+>>+endobj+6 0 obj+<<+/Contents 20 0 R /MediaBox [ 0 0 595.2756 841.8898 ] /Parent 17 0 R /Resources <<+/Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]+>> /Rotate 0 /Trans <<++>>+ /Type /Page+>>+endobj+7 0 obj+<<+/BitsPerComponent 8 /ColorSpace /DeviceRGB /Filter [ /ASCII85Decode /FlateDecode ] /Height 50 /Length 52 /Subtype /Image+ /Type /XObject /Width 80+>>+stream+Gb"0<5nO(s$j*+$ok\"<,:phuE28DlWiE)!WiE)!WiCM4mG0Wj~>endstream+endobj+8 0 obj+<<+/BitsPerComponent 8 /ColorSpace /DeviceRGB /Filter [ /ASCII85Decode /FlateDecode ] /Height 50 /Length 52 /Subtype /Image+ /Type /XObject /Width 80+>>+stream+Gb"0<0b"*_$j.XPp3P=V9h`PJ#]$<;WiE)!WiE)!WiFqe#e68t~>endstream+endobj+9 0 obj+<<+/A <<+/S /URI /Type /Action /URI (https://example.com/downloads/mineru/fixture/)+>> /Border [ 0 0 0 ] /Rect [ 72 483 200.556 495 ] /Subtype /Link /Type /Annot+>>+endobj+10 0 obj+<<+/A <<+/S /URI /Type /Action /URI (https://example.com/downloads/mineru/fixture/)+>> /Border [ 0 0 0 ] /Rect [ 72 471 129.015 483 ] /Subtype /Link /Type /Annot+>>+endobj+11 0 obj+<<+/A <<+/S /URI /Type /Action /URI (https://example.com/ref/a)+>> /Border [ 0 0 0 ] /Rect [ 72 423 173.043 435 ] /Subtype /Link /Type /Annot+>>+endobj+12 0 obj+<<+/A <<+/S /URI /Type /Action /URI (https://example.com/ref/b)+>> /Border [ 0 0 0 ] /Rect [ 175.545 423 276.588 435 ] /Subtype /Link /Type /Annot+>>+endobj+13 0 obj+<<+/A <<+/S /URI /Type /Action /URI (https://example.com/ref/c)+>> /Border [ 0 0 0 ] /Rect [ 279.09 423 379.629 435 ] /Subtype /Link /Type /Annot+>>+endobj+14 0 obj+<<+/Annots [ 9 0 R 10 0 R 11 0 R 12 0 R 13 0 R ] /Contents 21 0 R /MediaBox [ 0 0 595.2756 841.8898 ] /Parent 17 0 R /Resources <<+/Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ] /XObject <<+/FormXob.55532f1fc7ef8212e848f00ec587c85b 7 0 R /FormXob.abcafa7fe09633469641670e19e0fafe 8 0 R+>>+>> /Rotate 0+ /Trans <<++>> /Type /Page+>>+endobj+15 0 obj+<<+/PageMode /UseNone /Pages 17 0 R /Type /Catalog+>>+endobj+16 0 obj+<<+/Author (MinerU Test Suite) /CreationDate (D:20000101000000+00'00') /Creator (MinerU Test Suite) /Keywords (MinerU synthetic test fixture) /ModDate (D:20000101000000+00'00') /Producer (MinerU Test Suite)+ /Subject (Synthetic PDF regression fixture) /Title (MinerU Test Suite) /Trapped /False+>>+endobj+17 0 obj+<<+/Count 4 /Kids [ 4 0 R 5 0 R 6 0 R 14 0 R ] /Type /Pages+>>+endobj+18 0 obj+<<+/Filter [ /ASCII85Decode /FlateDecode ] /Length 591+>>+stream+Gau1,;/[+&%*.8o;u!W53,BtQ,`b;B&fU/e?Fim8"DH>!60j%mKsuJRm'+?L!so9&V`K#^qu?[bc8>_Q(R;Ma!k_4riY;JKU^o`![?07\3&P'42E6Wrg>L?^)5@ZM\*N1j`bS-_<lF2qm%D>]K'hJVmdKjfC_.sO<Xft?Ub.NPYG^FV!n+SSYWP\@q;cdLnc[Ag85IcDp.lG<9m$tVlEA*[qWj5d(j+<_;;4Im;;4Im;;VIlXT*Fmp<\!4p<\!4pOLQ@s#OnABKKsUBKQ46A(G&0hB+?YjN<#fmLPY8WjCW9Da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'W2'>"k*J13=#-f"t$t*E[=O4aH]/er2@Lu@K&DoYE<7MlE8K;0O7#*=t!^o>MRF\s)@'k!?<pe`t^CahV%et_=/,*_3KRKh[G6PrS`O`@"*]Q'*+AG+c'aP)2tDQK<+WapiJ2(ajZB@&^lf1&^lf5!F2PkNms#LNms#LNq<`.Abtgcbm<Q)bm<S/+3%lHd<]lD:`pr'88<R_FArDKWFW/r5FfC_;rc_Ib@EW<9VAYTE(_Vj:MNP5kWnSlU/t1NgKIJdAb<_sD<KA$m5PnK0\VVcQEF)L:oCg<&7$lPXHaX?8K2lO/&U#s3n:aCRS#IJFibIRFid3(d1PcMW>`7o=bj+h+IGA,GAr]E$$j^5'sg=s#T"+d`Zi7(7>ej?.R09S7fCV=F=8kqr@i=8bjdS<HoJ\X,?H')c&]j'pAV!=gg`4TS[c=MVo<fU0UoH"omLhaWantLH8BX6A^T9q/s^R&\.&>FF*#qIeNndTMHk,*;g!JL.[A_sk>'G$WT^ME@iCuCMQI@-]t:L:b,+K2=N8;Mlc9Sl'T)<;dZ=;ggsj%t_IH1Z/2I%G;HEX;'sFbk.qPZWG^D4;lA4;aG5U0F=hMBd>3(?nn:;.[K6LiKq[HETJZf~>endstream+endobj+xref+0 22+0000000000 65535 f+0000000073 00000 n+0000000114 00000 n+0000000221 00000 n+0000001154 00000 n+0000001359 00000 n+0000001564 00000 n+0000001769 00000 n+0000002008 00000 n+0000002247 00000 n+0000002427 00000 n+0000002608 00000 n+0000002769 00000 n+0000002935 00000 n+0000003100 00000 n+0000003463 00000 n+0000003533 00000 n+0000003849 00000 n+0000003928 00000 n+0000004610 00000 n+0000005492 00000 n+0000006282 00000 n+trailer+<<+/ID+[<b0ce4bb64c905e47caef5c06c690f477><b0ce4bb64c905e47caef5c06c690f477>]+% ReportLab generated PDF document -- digest (http://www.reportlab.com)++/Info 16 0 R+/Root 15 0 R+/Size 22+>>+startxref+7088+%%EOFdiff --git a/tests/unittest/test_flash_pdf_samples.py b/tests/unittest/test_flash_pdf_samples.pyindex 2f4d711b..f8529174 100644--- a/tests/unittest/test_flash_pdf_samples.py+++ b/tests/unittest/test_flash_pdf_samples.py@@ -7,6 +7,8 @@ from copy import deepcopyfrom pathlib import Pathfrom typing import Any+from pypdf import PdfReader+from mineru.backend.postprocess.page_blocks import process_page_blocksfrom mineru.backend.postprocess.pages import model_list_to_pagesfrom mineru.model.flash import PdfModel@@ -28,6 +30,14 @@ from mineru.types import MiddleJsonfrom mineru.utils.pdf_document import PDFDocument, get_lines_from_chars+_PROJECT_ROOT = Path(__file__).parents[2]+_DEMO_PDF_DIR = _PROJECT_ROOT / "demo" / "pdfs"+_FIXTURE_PDF_DIR = Path(__file__).resolve().parent / "pdfs"+_FLASH_SYNTHETIC_PDF_NAME = "flash_table_annotations_synthetic.pdf"+_CJK_SYNTHETIC_PDF_NAME = "native_cjk_layout_synthetic.pdf"+_SAFE_WATERMARK_TEXT = "MINERU TEST WATERMARK"++# demo4 第 9 至 11 页中实际跨物理行显示的 URL,用于确保纯正则拼接覆盖全部形态。_DEMO4_WRAPPED_URLS = ("https://doi.org/10.1007/s00259-025-07388-8",@@ -73,18 +83,26 @@ _DEMO4_WRAPPED_URLS = ()-def _native_model_list(pdf_name: str) -> list[list[dict[str, Any]]]:+def _native_model_list(+ pdf_name: str,+ *,+ pdf_dir: Path = _DEMO_PDF_DIR,+) -> list[list[dict[str, Any]]]:"""运行仓库内数字 PDF 样例并返回 Flash 原生模型输出。"""- pdf_path = Path(__file__).parents[2] / "demo" / "pdfs" / pdf_name+ pdf_path = pdf_dir / pdf_namewith PDFDocument(str(pdf_path)) as pdf_doc:return PdfModel().predict(pdf_doc)-def _txt_model_list(pdf_name: str) -> list[list[dict[str, Any]]]:+def _txt_model_list(+ pdf_name: str,+ *,+ pdf_dir: Path = _DEMO_PDF_DIR,+) -> list[list[dict[str, Any]]]:"""显式使用 Flash TXT 模式解析仓库内回归 PDF,禁止经过 auto 分类。"""- pdf_path = Path(__file__).parents[2] / "demo" / "pdfs" / pdf_name+ pdf_path = pdf_dir / pdf_namewith PDFDocument(pdf_path.read_bytes()) as pdf_doc:return PdfModel().predict(pdf_doc)@@ -174,21 +192,210 @@ def _blocks_containing(return [block for block in blocks if normalized_probe in _normalized_content_probe(str(block.get("content", "")))]-def test_all_demo_pdfs_keep_expected_txt_block_inventory() -> None:- """验证 15 份既有 demo PDF 在 TXT 模式下保持预期块库存与页脚迁移。"""-- pdf_names = sorted(- path.name- for path in (Path(__file__).parents[2] / "demo" / "pdfs").glob("*.pdf")- if path.name != "2407.00079v4_origi-10.pdf"- )- inventory: Counter[str] = Counter()- page_count = 0+def test_explicit_pdf_fixtures_keep_expected_txt_block_inventory() -> None:+ """验证显式登记的 demo 与合成 PDF 逐文件保持预期页数和块库存。"""++ expected_inventory = {+ "IEBM_A_2667169_O-5.pdf": (1, Counter({"equation": 16, "header": 2, "text": 12})),+ "caibao1.pdf": (+ 22,+ Counter(+ {+ "caption": 15,+ "footer": 22,+ "footnote": 17,+ "header": 43,+ "image": 14,+ "page_number": 22,+ "paragraph_title": 26,+ "table": 20,+ "text": 70,+ }+ ),+ ),+ "demo1.pdf": (+ 13,+ Counter(+ {+ "caption": 10,+ "doc_title": 1,+ "equation": 7,+ "footer": 1,+ "footnote": 5,+ "header": 12,+ "image": 8,+ "page_footnote": 1,+ "page_number": 12,+ "paragraph_title": 18,+ "table": 5,+ "text": 85,+ }+ ),+ ),+ "demo2.pdf": (+ 6,+ Counter(+ {+ "caption": 7,+ "doc_title": 1,+ "equation": 9,+ "footer": 1,+ "footnote": 2,+ "image": 8,+ "paragraph_title": 10,+ "table": 2,+ "text": 62,+ }+ ),+ ),+ "demo3.pdf": (+ 10,+ Counter(+ {+ "aside_text": 1,+ "caption": 8,+ "doc_title": 1,+ "equation": 8,+ "image": 1,+ "page_footnote": 6,+ "paragraph_title": 21,+ "table": 9,+ "text": 118,+ }+ ),+ ),+ "demo4.pdf": (+ 11,+ Counter(+ {+ "caption": 10,+ "doc_title": 1,+ "footer": 11,+ "header": 11,+ "image": 5,+ "page_footnote": 9,+ "page_number": 10,+ "paragraph_title": 12,+ "table": 1,+ "text": 112,+ }+ ),+ ),+ "demo6.pdf": (7, Counter({"image": 2, "paragraph_title": 9, "text": 24})),+ "mixed_elements_pages_03_06.pdf": (+ 4,+ Counter(+ {+ "caption": 4,+ "doc_title": 1,+ "equation": 1,+ "footer": 4,+ "header": 5,+ "image": 7,+ "page_number": 3,+ "paragraph_title": 5,+ "table": 1,+ "text": 32,+ }+ ),+ ),+ "mixed_elements_pages_07_10.pdf": (+ 4,+ Counter(+ {+ "caption": 6,+ "code": 3,+ "doc_title": 1,+ "footer": 3,+ "image": 2,+ "page_number": 4,+ "paragraph_title": 16,+ "table": 2,+ "text": 57,+ }+ ),+ ),+ "mixed_elements_pages_11_15.pdf": (+ 5,+ Counter(+ {+ "caption": 7,+ "doc_title": 1,+ "footer": 1,+ "header": 8,+ "image": 8,+ "page_footnote": 1,+ "page_number": 4,+ "paragraph_title": 13,+ "table": 1,+ "text": 50,+ }+ ),+ ),+ "mixed_elements_pages_39_40.pdf": (+ 2,+ Counter({"equation": 3, "page_number": 2, "paragraph_title": 2, "text": 15}),+ ),+ "small_ocr.pdf": (8, Counter({"header": 49, "image": 447})),+ "中文论文.pdf": (+ 10,+ Counter(+ {+ "caption": 18,+ "doc_title": 1,+ "equation": 6,+ "footnote": 1,+ "header": 22,+ "image": 8,+ "page_footnote": 4,+ "page_number": 9,+ "paragraph_title": 20,+ "table": 3,+ "text": 106,+ }+ ),+ ),+ _FLASH_SYNTHETIC_PDF_NAME: (+ 8,+ Counter(+ {+ "caption": 6,+ "footer": 1,+ "footnote": 3,+ "page_number": 8,+ "table": 6,+ "text": 16,+ }+ ),+ ),+ _CJK_SYNTHETIC_PDF_NAME: (+ 4,+ Counter(+ {+ "caption": 2,+ "image": 2,+ "index": 1,+ "page_number": 4,+ "paragraph_title": 2,+ "text": 12,+ }+ ),+ ),+ }+ pdf_paths = {+ pdf_name: _DEMO_PDF_DIR / pdf_name+ for pdf_name in expected_inventory+ }+ pdf_paths[_FLASH_SYNTHETIC_PDF_NAME] = _FIXTURE_PDF_DIR / _FLASH_SYNTHETIC_PDF_NAME+ pdf_paths[_CJK_SYNTHETIC_PDF_NAME] = _FIXTURE_PDF_DIR / _CJK_SYNTHETIC_PDF_NAME+ actual_inventory: dict[str, tuple[int, Counter[str]]] = {}unsafe_content: list[tuple[str, int, int, list[str]]] = []- for pdf_name in pdf_names:- model_list = _txt_model_list(pdf_name)- page_count += len(model_list)- inventory.update(block["type"] for page in model_list for block in page)+ for pdf_name, pdf_path in pdf_paths.items():+ model_list = _txt_model_list(pdf_name, pdf_dir=pdf_path.parent)+ actual_inventory[pdf_name] = (+ len(model_list),+ Counter(block["type"] for page in model_list for block in page),+ )unsafe_content.extend((pdf_name, page_index, block_index, unsafe_chars)for page_index, page in enumerate(model_list)@@ -196,29 +403,8 @@ def test_all_demo_pdfs_keep_expected_txt_block_inventory() -> None:if (unsafe_chars := _unsafe_flash_content_characters(str(block.get("content", "")))))- assert len(pdf_names) == 15- assert page_count == 218- assert sum(inventory.values()) == 2591+ assert actual_inventory == expected_inventoryassert unsafe_content == []- assert inventory == Counter(- {- "text": 896,- "image": 530,- "paragraph_title": 214,- "header": 180,- "page_number": 179,- "footer": 177,- "table": 135,- "caption": 124,- "equation": 50,- "footnote": 39,- "code": 33,- "page_footnote": 21,- "doc_title": 10,- "index": 2,- "aside_text": 1,- }- )def test_demo1_keeps_five_real_tables_without_formula_false_positive() -> None:@@ -1265,192 +1451,83 @@ def test_demo4_nct00083083_targeted_flash_regressions() -> None:assert "fimmu.2023.1222129" in str(reference48["content"])-def test_demo5_targeted_table_and_footer_regressions() -> None:- """验证 demo5 代表页表格完整、框内无残文且页码外图片成为页脚。"""+def test_synthetic_flash_table_annotation_regressions() -> None:+ """验证合成 Flash 夹具覆盖表格、表注、跨页边界和空图片页脚。"""- model_list = _native_model_list("demo5.pdf")+ model_list = _native_model_list(+ _FLASH_SYNTHETIC_PDF_NAME,+ pdf_dir=_FIXTURE_PDF_DIR,+ )- sparse_table_counts = {- 4: 2,- 49: 1,- 55: 1,- 56: 2,- 59: 1,- 61: 1,- 83: 2,- 84: 3,- 85: 3,- 87: 1,- }- for page_number, expected_count in sparse_table_counts.items():- page = model_list[page_number - 1]- table_blocks = [block for block in page if block["type"] == "table"]- assert len(table_blocks) == expected_count- for table_block in table_blocks:- table_bbox = table_block["bbox"]- assert not [- block- for block in page- if block["type"] == "text"- and table_bbox[0] <= (block["bbox"][0] + block["bbox"][2]) / 2 <= table_bbox[2]- and table_bbox[1] <= (block["bbox"][1] + block["bbox"][3]) / 2 <= table_bbox[3]- ]-- for page_number in (9, 10, 22, 38, 70, 77):- page = model_list[page_number - 1]- table_blocks = [block for block in page if block["type"] == "table"]- assert len(table_blocks) == 1- table_bbox = table_blocks[0]["bbox"]- residual_text = [+ assert len(model_list) == 8++ page2 = model_list[1]+ page2_tables = [block for block in page2 if block["type"] == "table"]+ assert [block["bbox"] for block in page2_tables] == [+ [0.121, 0.168, 0.877, 0.302],+ [0.121, 0.37, 0.877, 0.504],+ ]+ assert [block["content"].splitlines()[0] for block in page2_tables] == [+ "ITEM VALUE STATE",+ "METRIC LOW HIGH",+ ]+ assert [[child["type"] for child in group["content"]] for group in _grouped_visual_blocks(page2, "table")] == [+ ["table_caption", "table_body"],+ ["table_caption", "table_body"],+ ]+ for table_block in page2_tables:+ table_bbox = table_block["bbox"]+ assert not [block- for block in page+ for block in page2if block["type"] == "text"and table_bbox[0] <= (block["bbox"][0] + block["bbox"][2]) / 2 <= table_bbox[2]and table_bbox[1] <= (block["bbox"][1] + block["bbox"][3]) / 2 <= table_bbox[3]]- assert not residual_text-- repaired_table_bboxes = {- 23: [0.034, 0.151, 0.968, 0.696],- 24: [0.034, 0.151, 0.968, 0.696],- 36: [0.033, 0.151, 0.967, 0.525],- 71: [0.057, 0.151, 0.943, 0.685],- 75: [0.057, 0.151, 0.943, 0.684],- 81: [0.143, 0.086, 0.857, 0.785],- }- for page_number, expected_bbox in repaired_table_bboxes.items():- page = model_list[page_number - 1]- table_blocks = [block for block in page if block["type"] == "table"]- assert [block["bbox"] for block in table_blocks] == [expected_bbox]- assert not [block for block in page if block["type"] == "code"]- assert not [- block- for block in page- if block["type"] in {"text", "header"}- and expected_bbox[0] <= (block["bbox"][0] + block["bbox"][2]) / 2 <= expected_bbox[2]- and expected_bbox[1] <= (block["bbox"][1] + block["bbox"][3]) / 2 <= expected_bbox[3]- ]-- page77_note = _blocks_containing(model_list[76], "注:(1)指气量")- assert len(page77_note) == 1- assert page77_note[0]["type"] == "footnote"-- merged_table_footnotes = {- 6: (- [0.086, 0.412, 0.522, 0.567],- "注:(1)指主要生产单元所采用的工艺名称。",- "(7)指设计年生产时间。",- ),- 7: (- [0.086, 0.552, 0.572, 0.652],- "注:(1)指材料种类,选填“原料”或“辅料”。",- "(4)指有毒有害物质或元素",- ),- 31: (- [0.086, 0.535, 0.36, 0.675],- "注:(1)指主要生产设施。",- "(4)指有组织排放或无组织排放。",- ),- }- for page_number, (expected_bbox, prefix, tail_probe) in merged_table_footnotes.items():- page = model_list[page_number - 1]- footnotes = [block for block in page if block["type"] == "footnote"]- assert len(footnotes) == 1- footnote = footnotes[0]- assert footnote["bbox"] == expected_bbox- assert str(footnote["content"]).startswith(prefix)- assert _blocks_containing(page, tail_probe) == [footnote]- assert not _blocks_containing(- [block for block in page if block["type"] == "text"],- tail_probe,- )-- table_blocks = _grouped_visual_blocks(page, "table")- assert len(table_blocks) == 1- assert [child["type"] for child in table_blocks[0]["content"]][-2:] == [- "table_body",- "table_footnote",- ]- table_footnote = table_blocks[0]["content"][-1]- assert table_footnote["bbox"] == expected_bbox- assert _normalized_content_probe(tail_probe) in _normalized_content_probe(str(table_footnote["content"]))- expected_footnote_pages = {2, 6, 7, 31, 36, 39, 43, 49, 53, 55, 57, 58, 59, 77}- assert {- page_number- for page_number, page in enumerate(model_list, start=1)- if any(block["type"] == "footnote" for block in page)- } == expected_footnote_pages- assert sum(block["type"] == "footnote" for page in model_list for block in page) == 14- assert sum(block["type"] == "caption" for page in model_list for block in page) == 25-- page2_visual_blocks = [block for block in model_list[1] if block["type"] in {"caption", "table", "footnote"}]- assert [block["type"] for block in page2_visual_blocks] == [- "caption",- "table",- "footnote",- ]- assert [block["bbox"] for block in page2_visual_blocks] == [- [0.403, 0.132, 0.597, 0.144],- [0.121, 0.147, 0.879, 0.871],- [0.151, 0.873, 0.53, 0.886],- ]- assert "表1 排污单位基本信息表" not in str(page2_visual_blocks[1]["content"])- assert "指生产经营场所地址所在地邮政编码" not in str(page2_visual_blocks[1]["content"])- assert [child["type"] for child in _grouped_visual_blocks(model_list[1], "table")[0]["content"]] == [+ page3 = model_list[2]+ page3_footnotes = [block for block in page3 if block["type"] == "footnote"]+ assert len(page3_footnotes) == 1+ assert page3_footnotes[0]["bbox"] == [0.128, 0.356, 0.505, 0.395]+ assert str(page3_footnotes[0]["content"]).endswith(+ "Its second indented continuation completes the annotation."+ )+ assert [child["type"] for child in _grouped_visual_blocks(page3, "table")[0]["content"]] == ["table_caption","table_body","table_footnote",]- page4_table_groups = _grouped_visual_blocks(model_list[3], "table")- assert [[child["type"] for child in group["content"]] for group in page4_table_groups] == [- ["table_caption", "table_body"],- ["table_caption", "table_body"],- ]- assert [tuple(round(value * 1000) for value in group["content"][0]["bbox"]) for group in page4_table_groups] == [- (425, 308, 575, 326),- (406, 619, 594, 637),- ]+ page4 = model_list[3]+ assert _blocks_containing(page4, "This sentence is inside the border")[0]["type"] == "table"+ assert not [block for block in page4 if block["type"] == "footnote"]- for page_number in (65, 66):- in_border_note = _blocks_containing(- model_list[page_number - 1],- "注:设计贮存/处置危险废物数量",- )- assert len(in_border_note) == 1- assert in_border_note[0]["type"] == "table"- assert not [block for block in model_list[page_number - 1] if block["type"] == "footnote"]- page62_note = _blocks_containing(- model_list[61],- "排入城镇集中污水处理设施的生活污水",- )- page86_table20 = _blocks_containing(model_list[85], "表20 改正规定信息表")- assert len(page62_note) == len(page86_table20) == 1- assert page62_note[0]["type"] == page86_table20[0]["type"] == "text"-- page36_footnotes = [block for block in model_list[35] if block["type"] == "footnote"]- assert [block["bbox"] for block in page36_footnotes] == [[0.086, 0.587, 0.404, 0.654]]- page57_footnotes = [block for block in model_list[56] if block["type"] == "footnote"]- page58_continuation = [- block- for block in _blocks_containing(- model_list[57],- "可通过排污许可证管理信息平台中的GIS系统点选后自动生成经纬度",- )- if block["type"] == "text"+ page5 = model_list[4]+ assert _blocks_containing(page5, "ITEM_001 and VALUE_002")[0]["type"] == "text"+ assert not [block for block in page5 if block["type"] in {"caption", "code", "footnote", "table"}]++ page6 = model_list[5]+ token_table = _blocks_containing(page6, "ROW_001")+ assert len(token_table) == 1+ assert token_table[0]["type"] == "table"+ assert not [block for block in page6 if block["type"] == "code"]+ assert [child["type"] for child in _grouped_visual_blocks(page6, "table")[0]["content"]] == [+ "table_caption",+ "table_body",+ "table_footnote",]- assert len(page57_footnotes) == len(page58_continuation) == 1- assert page57_footnotes[0]["type"] == "footnote"- assert page58_continuation[0]["type"] == "text"- assert page58_continuation[0]["bbox"] == [0.086, 0.155, 0.803, 0.221]- page9 = model_list[8]- page_number_block = next(block for block in page9 if block["type"] == "page_number")- empty_footer = next(block for block in page9 if block["type"] == "footer" and not str(block["content"]).strip())+ page7 = model_list[6]+ page8 = model_list[7]+ assert _blocks_containing(page7, "annotation ends on page seven")[0]["type"] == "footnote"+ assert _blocks_containing(page8, "must not merge into the previous page footnote")[0]["type"] == "text"+ assert not [block for block in page8 if block["type"] == "footnote"]++ page_number_block = next(block for block in page8 if block["type"] == "page_number")+ empty_footer = next(block for block in page8 if block["type"] == "footer")+ assert empty_footer["content"] == ""+ assert empty_footer["bbox"] == [0.399, 0.968, 0.601, 0.999]assert empty_footer["bbox"][1] > page_number_block["bbox"][3]--def test_demo6_default3_targeted_title_regressions() -> None:"""验证 demo6 的五个正文负样本和九个真实章节标题。"""@@ -1732,43 +1809,112 @@ def test_iebm_left_indented_compact_formula_is_equation() -> None:assert not [block for block in page if block["type"] in {"caption", "footnote"}]-def test_npu_numbered_figure_captions_are_independent_annotations() -> None:- """验证 NPU 图注稳定、跨行 URL 连续,且多条独立 URL 不会相连。"""+def test_synthetic_cjk_captions_and_urls_are_independent_annotations() -> None:+ """验证合成 CJK 图注稳定、跨行 URL 连续且多条独立 URL 不相连。"""- model_list = _txt_model_list("NPU_开发环境部署_参考指南.pdf")- expected_counts = {6: 1, 7: 1, 14: 2, 15: 2, 16: 2, 17: 1, 18: 1, 19: 2, 20: 2}+ model_list = _txt_model_list(+ _CJK_SYNTHETIC_PDF_NAME,+ pdf_dir=_FIXTURE_PDF_DIR,+ )+ page4 = model_list[3]+ captions = [block for block in page4 if block["type"] == "caption"]- assert {- page_number: sum(block["type"] == "caption" for block in model_list[page_number - 1]) for page_number in expected_counts- } == expected_counts- assert sum(block["type"] == "caption" for page in model_list for block in page) == 14- assert all(str(block["content"]).startswith("图 ") for page in model_list for block in page if block["type"] == "caption")+ assert [block["content"] for block in captions] == [+ "图 1 合成示意图 A",+ "图 2 合成示意图 B",+ ]assert not [block for page in model_list for block in page if block["type"] == "footnote"]- docker_url = "https://download.docker.com/linux/ubuntu/dists/"- assert any(docker_url in str(block.get("content", "")) for block in model_list[8])+ wrapped_url = "https://example.com/downloads/mineru/fixture/"+ wrapped_block = next(+ str(block.get("content", ""))+ for block in page4+ if wrapped_url in str(block.get("content", ""))+ )+ assert wrapped_block == f"<hyperlink>{wrapped_url}<url>{wrapped_url}</url></hyperlink>"reference_urls = [- "https://blog.csdn.net/hzgnet2021/article/details/134925349",- "https://blog.csdn.net/NuOne_plus/article/details/120330419",- "https://blog.csdn.net/qq_38567039/article/details/124848621",+ "https://example.com/ref/a",+ "https://example.com/ref/b",+ "https://example.com/ref/c",]reference_block = next(str(block.get("content", ""))- for block in model_list[21]+ for block in page4if reference_urls[0] in str(block.get("content", "")))- reference_visible_text = inline_plain_text(- parse_inline_content(reference_block)- )- assert " ".join(reference_urls) in reference_visible_text- assert not any(- first + second in reference_visible_text- for first, second in zip(reference_urls, reference_urls[1:])- )+ reference_visible_text = inline_plain_text(parse_inline_content(reference_block))+ assert reference_visible_text == " ".join(reference_urls)+ assert not any(first + second in reference_visible_text for first, second in zip(reference_urls, reference_urls[1:]))assert all(f"<url>{url}</url>" in reference_block for url in reference_urls)+def test_synthetic_cjk_fixture_contains_only_safe_watermarks_and_links() -> None:+ """验证合成 CJK PDF 仅含安全旋转水印和预期 URI 注解。"""++ pdf_path = _FIXTURE_PDF_DIR / _CJK_SYNTHETIC_PDF_NAME+ with PDFDocument(pdf_path.read_bytes()) as document:+ rotated_lines = [+ "".join(str(span.get("text", "")) for span in line.get("spans", []))+ for page_index in range(len(document))+ for line in document.get_page_lines(page_index)+ if float(line.get("rotation", 0.0))+ ]+ model_list = PdfModel().predict(document)++ expected_watermark_row = " ".join([_SAFE_WATERMARK_TEXT] * 4)+ assert len(rotated_lines) == 16+ assert {text.replace("\r", "").replace("\n", "").strip() for text in rotated_lines} == {+ expected_watermark_row+ }+ assert not [+ block+ for page in model_list+ for block in page+ if _SAFE_WATERMARK_TEXT in str(block.get("content", ""))+ ]++ reader = PdfReader(pdf_path)+ link_targets = [+ str(annotation.get_object()["/A"]["/URI"])+ for annotation in reader.pages[3]["/Annots"]+ ]+ assert link_targets == [+ "https://example.com/downloads/mineru/fixture/",+ "https://example.com/downloads/mineru/fixture/",+ "https://example.com/ref/a",+ "https://example.com/ref/b",+ "https://example.com/ref/c",+ ]+++def test_synthetic_pdf_fixtures_have_neutral_metadata_and_catalogs() -> None:+ """验证两份合成 PDF 均无加密、附件、脚本、隐藏元数据或无关批注。"""++ expected_metadata = {+ "/Author": "MinerU Test Suite",+ "/CreationDate": "D:20000101000000+00'00'",+ "/Creator": "MinerU Test Suite",+ "/Keywords": "MinerU synthetic test fixture",+ "/ModDate": "D:20000101000000+00'00'",+ "/Producer": "MinerU Test Suite",+ "/Subject": "Synthetic PDF regression fixture",+ "/Title": "MinerU Test Suite",+ "/Trapped": "/False",+ }+ expected_annotation_counts = {+ _FLASH_SYNTHETIC_PDF_NAME: [0] * 8,+ _CJK_SYNTHETIC_PDF_NAME: [0, 0, 0, 5],+ }+ for pdf_name, annotation_counts in expected_annotation_counts.items():+ reader = PdfReader(_FIXTURE_PDF_DIR / pdf_name)++ assert not reader.is_encrypted+ assert dict(reader.metadata or {}) == expected_metadata+ assert set(reader.trailer["/Root"]) == {"/PageMode", "/Pages", "/Type"}+ assert [len(page.get("/Annots", [])) for page in reader.pages] == annotation_counts++def test_frozen_soil_page3_formula3_remains_one_equation() -> None:"""验证中文论文第三页公式编号完整转为 tag 并归入单个公式块。"""diff --git a/tests/unittest/test_pdf_analyze_block_content.py b/tests/unittest/test_pdf_analyze_block_content.pyindex d7f7f5e5..b02c146b 100644--- a/tests/unittest/test_pdf_analyze_block_content.py+++ b/tests/unittest/test_pdf_analyze_block_content.py@@ -29,7 +29,7 @@ from mineru.utils.pdf_document import PDFDocument_PROJECT_ROOT = Path(__file__).resolve().parents[2]-_NPU_PDF_PATH = _PROJECT_ROOT / "demo" / "pdfs" / "NPU_开发环境部署_参考指南.pdf"+_SYNTHETIC_CJK_PDF_PATH = _PROJECT_ROOT / "tests" / "unittest" / "pdfs" / "native_cjk_layout_synthetic.pdf"def _build_text_lines(*contents: str) -> list[_AnalyzeLine]:@@ -772,15 +772,16 @@ def test_existing_text_content_is_preserved_while_lines_are_refreshed() -> None:assert block["lines"] == [{"bbox": [0.0, 0.0, 0.5, 0.01]}]-def test_npu_page_three_low_visual_runs_keep_index_line_structure() -> None:- """验证 Low/TXT 的 Flash visual run 拆分不会破坏 NPU 的 24 行目录。"""- document = PDFDocument(_NPU_PDF_PATH.read_bytes())+def test_synthetic_cjk_low_visual_runs_keep_index_line_structure() -> None:+ """验证 Low/TXT 的 Flash visual run 拆分不会破坏合成 PDF 的 24 行目录。"""++ document = PDFDocument(_SYNTHETIC_CJK_PDF_PATH.read_bytes())try:- page = document[2]+ page = document[1]page_size = tuple(float(value) for value in page.size)index_block = {"type": BlockType.INDEX,- "bbox": [0.064, 0.17, 0.943, 0.689],+ "bbox": [0.109, 0.11, 0.874, 0.832],"angle": 0,"content": "",}@@ -798,16 +799,16 @@ def test_npu_page_three_low_visual_runs_keep_index_line_structure() -> None:page_size,)- flash_index_block = next(block for block in PdfModel().predict(document)[2] if block.get("type") == BlockType.INDEX)+ flash_index_block = next(block for block in PdfModel().predict(document)[1] if block.get("type") == BlockType.INDEX)flash_content = inline_plain_text(parse_inline_content(str(flash_index_block["content"])))assert index_block["content"] == flash_contentassert len(str(index_block["content"]).splitlines()) == 24- assert str(index_block["content"]).splitlines()[0] == "1 前言 1"- assert str(index_block["content"]).splitlines()[-1] == "5 附录: 19"+ assert str(index_block["content"]).splitlines()[0] == "1 合成章节 1 1"+ assert str(index_block["content"]).splitlines()[-1] == "24 合成章节 24 24"assert index_block["type"] == BlockType.INDEX- assert index_block["bbox"] == [0.064, 0.17, 0.943, 0.689]+ assert index_block["bbox"] == [0.109, 0.11, 0.874, 0.832]assert index_block["angle"] == 0finally:document.close()diff --git a/tests/unittest/test_pdf_classify.py b/tests/unittest/test_pdf_classify.pyindex 4a773b7c..c2e58298 100644--- a/tests/unittest/test_pdf_classify.py+++ b/tests/unittest/test_pdf_classify.py@@ -20,6 +20,7 @@ from mineru.utils.pdf_document import PDFDocumentREPO_ROOT = Path(__file__).resolve().parents[2]MIXED_ELEMENTS_PDF = REPO_ROOT / "demo" / "pdfs" / "mixed_elements_pages_07_10.pdf"+SYNTHETIC_FLASH_PDF = REPO_ROOT / "tests" / "unittest" / "pdfs" / "flash_table_annotations_synthetic.pdf"def _write_single_sample_page(content_data: bytes) -> bytes:@@ -292,7 +293,6 @@ def test_classifier_returns_ocr_when_exact_content_analysis_fails(("demo2.pdf", "txt"),("demo3.pdf", "txt"),("demo4.pdf", "txt"),- ("demo5.pdf", "txt"),("demo6.pdf", "txt"),("mixed_elements_pages_03_06.pdf", "txt"),("mixed_elements_pages_07_10.pdf", "txt"),@@ -309,3 +309,10 @@ def test_demo_pdf_classification_regressions(pdf_path = REPO_ROOT / "demo" / "pdfs" / pdf_namewith PDFDocument(str(pdf_path)) as pdf_doc:assert pdf_doc.classify() == expected_mode+++def test_synthetic_flash_fixture_classification_regression() -> None:+ """验证脱敏合成表格夹具继续稳定分类为 TXT。"""++ with PDFDocument(str(SYNTHETIC_FLASH_PDF)) as pdf_doc:+ assert pdf_doc.classify() == "txt"diff --git a/tests/unittest/test_pdf_native_script_detection.py b/tests/unittest/test_pdf_native_script_detection.pyindex 7d58358c..3c9e080f 100644--- a/tests/unittest/test_pdf_native_script_detection.py+++ b/tests/unittest/test_pdf_native_script_detection.py@@ -344,28 +344,38 @@ def test_chinese_reference_line_only_marks_the_reference() -> None:@pytest.mark.parametrize(- ("page_index", "probe"),+ ("probe", "minimum_font_count"),[- pytest.param(4, "• 技术支持工程师", id="bullet-text"),- pytest.param(5, "• Acuity Toolkit", id="mixed-font-bullet-text"),- pytest.param(6, "• Ubuntu 16.04", id="version-bullet-text"),+ pytest.param("• 合成支持工程师 Support Engineer", 2, id="bullet-text"),+ pytest.param("• 混合字体工具 Acuity Toolkit", 2, id="mixed-font-bullet-text"),+ pytest.param("• 测试系统 Ubuntu 24.04", 2, id="version-bullet-text"),pytest.param(- 10,- "Vivante_acuity_toolkit_binary_6.6.1_20220329_ubuntu20.04.tgz",+ "mineru_toolkit_binary_1.0.0_linux_x86_64.tgz",+ 1,id="filename-descender",),],)-def test_npu_plain_text_does_not_gain_script_tags(page_index: int, probe: str) -> None:- """验证项目符号、混合字体和文件名降部字符不会驱动整行上下标误判。"""+def test_synthetic_cjk_plain_text_does_not_gain_script_tags(+ probe: str,+ minimum_font_count: int,+) -> None:+ """验证合成项目符号、混合字体和文件名降部字符不会触发上下标误判。"""+matching_lines = _lines_chars_containing(- _DEMO_PDF_DIR / "NPU_开发环境部署_参考指南.pdf",- page_index,+ _FIXTURE_PDF_DIR / "native_cjk_layout_synthetic.pdf",+ 2,probe,)contents = [_render_chars(chars) for chars in matching_lines]+ font_names = {+ str((char.get("font") or {}).get("name", ""))+ for chars in matching_lines+ for char in chars+ }assert contents+ assert len(font_names) >= minimum_font_countassert all("<sup>" not in content and "<sub>" not in content for content in contents)