Skip to content

Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.

feat: enhance table rendering with geometry-aware HTML serialization for native tables

myhlolic50995e4391e
diff --git a/mineru/backend/analysis/pdf/tables.py b/mineru/backend/analysis/pdf/tables.py
index 0972642c..8023d034 100644
--- a/mineru/backend/analysis/pdf/tables.py
+++ b/mineru/backend/analysis/pdf/tables.py
@@ -26,8 +26,9 @@ from ....model.flash.pdf.table_recovery import (
coerce_native_table_rules,
recover_native_pdf_table,
)
+from ....model.flash.pdf.table_text_styles import render_native_table_html_with_scripts
from ....model.ocr.image import mask_formula_regions_for_ocr_det
-from ....model.flash.pdf.document import PDFPage, get_lines_from_chars
+from ....model.flash.pdf.document import PDFPage, PDFPageTextGeometry, get_lines_from_chars
from ....model.flash.pdf.spatial_text import project_ocr_table_text
from .constants import (
@@ -104,18 +105,13 @@ def _has_non_empty_table_content(block: dict[str, Any]) -> bool:
def _mark_native_table_complex_entries(
table_entries: list[dict[str, Any]],
page_blocks: list[dict[str, Any]],
- layout_res: list[dict[str, Any]],
page_size: tuple[int, int],
- *,
- formula_is_complex: bool,
) -> None:
"""按现有归属几何标记含模型语义对象或重叠表格的候选。"""
for block in page_blocks:
block_type = block.get("type")
- if block_type not in _NATIVE_TABLE_ALWAYS_COMPLEX_BLOCK_TYPES and not (
- formula_is_complex and block_type in _NATIVE_TABLE_FORMULA_BLOCK_TYPES
- ):
+ if block_type not in _NATIVE_TABLE_ALWAYS_COMPLEX_BLOCK_TYPES:
continue
block_bbox = _bbox_to_pixel_bbox(block.get("bbox"), page_size)
if block_bbox is None:
@@ -124,19 +120,6 @@ def _mark_native_table_complex_entries(
if owner is not None:
owner["complex_reasons"].add(str(block.get("type")))
- if formula_is_complex:
- # inline_formula 不会进入 VL-style block,High 必须从原始 layout 结果单独参与门控。
- for layout_item in layout_res:
- label = str(layout_item.get("label") or layout_item.get("type") or "")
- if label not in _NATIVE_TABLE_FORMULA_LAYOUT_LABELS:
- continue
- formula_bbox = _bbox_to_pixel_bbox(layout_item.get("bbox"), page_size)
- if formula_bbox is None:
- continue
- owner = _select_table_owner(formula_bbox, table_entries)
- if owner is not None:
- owner["complex_reasons"].add(label)
-
for entry_index, table_entry in enumerate(table_entries):
table_bbox = table_entry["table_bbox"]
for peer_entry in table_entries[entry_index + 1 :]:
@@ -186,13 +169,13 @@ def _remove_native_table_internal_text_blocks(
return removed_count
-def _remove_medium_native_table_formula_items(
+def _remove_native_table_formula_items(
page_blocks: list[dict[str, Any]],
layout_res: list[dict[str, Any]],
accepted_entries: list[dict[str, Any]],
page_size: tuple[int, int],
) -> tuple[int, int]:
- """原子删除 Medium 原生命中表内的公式 block 与原始 layout 项。"""
+ """原子删除 Medium/High 原生命中表内的公式 block 与原始 layout 项。"""
if not accepted_entries:
return 0, 0
@@ -233,6 +216,7 @@ def _apply_native_txt_table_priority(
images_list: list[dict[str, Any]],
*,
effort: Literal["medium", "high"],
+ page_text_geometries: list[PDFPageTextGeometry | None] | None = None,
) -> _NativeTablePrioritySummary:
"""在 Medium/High TXT 模型表格识别前回填高置信原生 HTML。"""
@@ -276,9 +260,7 @@ def _apply_native_txt_table_priority(
_mark_native_table_complex_entries(
table_entries,
page_blocks,
- layout_res,
page_size,
- formula_is_complex=effort == "high",
)
for table_entry in table_entries:
if table_entry["complex_reasons"]:
@@ -293,7 +275,12 @@ def _apply_native_txt_table_priority(
continue
try:
- native_chars = tuple(pdf_page.get_chars())
+ page_text_geometry = page_text_geometries[page_idx] if page_text_geometries is not None else None
+ if page_text_geometry is None:
+ page_text_geometry = pdf_page.get_chars_with_geometry()
+ if page_text_geometries is not None:
+ page_text_geometries[page_idx] = page_text_geometry
+ native_chars = tuple(page_text_geometry.chars)
native_rules = coerce_native_table_rules(pdf_page.get_drawing_lines())
native_rectangles = coerce_native_table_rectangles(pdf_page.get_path_infos())
native_page_size = tuple(float(value) for value in pdf_page.size)
@@ -318,16 +305,15 @@ def _apply_native_txt_table_priority(
rejected += 1
continue
try:
- result = recover_native_pdf_table(
- NativeTableInput(
- table_bbox=table_bbox,
- page_size=native_page_size,
- angle=_normalize_visual_block_angle(table_block.get("angle", 0)),
- chars=native_chars,
- drawing_lines=native_rules,
- rectangles=native_rectangles,
- )
+ table_input = NativeTableInput(
+ table_bbox=table_bbox,
+ page_size=native_page_size,
+ angle=_normalize_visual_block_angle(table_block.get("angle", 0)),
+ chars=native_chars,
+ drawing_lines=native_rules,
+ rectangles=native_rectangles,
)
+ result = recover_native_pdf_table(table_input)
except Exception as exc:
errors += 1
logger.warning(
@@ -342,7 +328,12 @@ def _apply_native_txt_table_priority(
f"page_idx={page_idx}, bbox={table_block.get('bbox')}"
)
continue
- table_block["content"] = result.html
+ table_block["content"] = render_native_table_html_with_scripts(
+ result,
+ table_input,
+ page_text_geometry.tight_bboxes,
+ page_text_geometry.origins,
+ )
accepted_entries.append(table_entry)
accepted += 1
logger.debug(
@@ -351,17 +342,16 @@ def _apply_native_txt_table_priority(
f"source={result.source}, confidence={result.confidence:.3f}"
)
- if effort == "medium":
- page_removed_formula_blocks, page_removed_formula_layout_items = (
- _remove_medium_native_table_formula_items(
- page_blocks,
- layout_res,
- accepted_entries,
- page_size,
- )
+ page_removed_formula_blocks, page_removed_formula_layout_items = (
+ _remove_native_table_formula_items(
+ page_blocks,
+ layout_res,
+ accepted_entries,
+ page_size,
)
- removed_formula_blocks += page_removed_formula_blocks
- removed_formula_layout_items += page_removed_formula_layout_items
+ )
+ removed_formula_blocks += page_removed_formula_blocks
+ removed_formula_layout_items += page_removed_formula_layout_items
removed_internal_text += _remove_native_table_internal_text_blocks(
page_blocks,
diff --git a/mineru/backend/analysis/pdf/text/content.py b/mineru/backend/analysis/pdf/text/content.py
index cf445a09..d81dbb45 100644
--- a/mineru/backend/analysis/pdf/text/content.py
+++ b/mineru/backend/analysis/pdf/text/content.py
@@ -324,6 +324,7 @@ def _fill_window_block_content_and_lines(
parse_mode: Literal["txt", "ocr"],
ocr_det_type: set[str],
local_model_context: HybridLocalModelContext,
+ page_text_geometries: list[PDFPageTextGeometry | None] | None = None,
) -> list[list[dict[str, Any]]]:
"""按页完成 span 回填与行级元数据构造,返回不含页面级 sidecar 的 model list。"""
page_counts = {
@@ -333,6 +334,8 @@ def _fill_window_block_content_and_lines(
"inline_formulas": len(inline_formula_list),
"ocr_results": len(ocr_res_list),
}
+ if page_text_geometries is not None:
+ page_counts["text_geometries"] = len(page_text_geometries)
if len(set(page_counts.values())) != 1:
raise ValueError(f"Hybrid block content page count mismatch: {page_counts}")
@@ -346,12 +349,15 @@ def _fill_window_block_content_and_lines(
list[PDFTextLinkLine],
]
] = []
- for image_dict, pdf_page, page_model_list, page_inline_formula_list, page_ocr_res_list in zip(
- images_list,
- pdf_pages,
- model_list,
- inline_formula_list,
- ocr_res_list,
+ for page_idx, (image_dict, pdf_page, page_model_list, page_inline_formula_list, page_ocr_res_list) in enumerate(
+ zip(
+ images_list,
+ pdf_pages,
+ model_list,
+ inline_formula_list,
+ ocr_res_list,
+ strict=True,
+ )
):
page_pil_image = image_dict["img_pil"]
render_scale = float(image_dict["scale"])
@@ -365,7 +371,7 @@ def _fill_window_block_content_and_lines(
style_lines: list[PDFTextStyleLine] = []
link_lines: list[PDFTextLinkLine] = []
if parse_mode == "txt":
- page_text_geometry = None
+ page_text_geometry = page_text_geometries[page_idx] if page_text_geometries is not None else None
try:
page_char_count = pdf_page.get_char_count()
except Exception:
@@ -380,7 +386,12 @@ def _fill_window_block_content_and_lines(
_line_items,
style_lines,
link_lines,
- ) = build_pdf_native_visual_lines_and_styles(pdf_page)
+ ) = build_pdf_native_visual_lines_and_styles(
+ pdf_page,
+ page_text_geometry=page_text_geometry,
+ )
+ if page_text_geometries is not None:
+ page_text_geometries[page_idx] = page_text_geometry
page_spans = _fill_native_pdf_text_spans(
pdf_page,
page_spans,
diff --git a/mineru/backend/analysis/pdf/window.py b/mineru/backend/analysis/pdf/window.py
index c39763a3..3599af08 100644
--- a/mineru/backend/analysis/pdf/window.py
+++ b/mineru/backend/analysis/pdf/window.py
@@ -10,7 +10,7 @@ import numpy as np
from loguru import logger
from ....model.runtime.hybrid import HybridLocalModelContext
-from ....model.flash.pdf.document import PDFDocument, PDFPage
+from ....model.flash.pdf.document import PDFDocument, PDFPage, PDFPageTextGeometry
from .images import load_images_from_pdf_bytes_range
from ..contracts import AnalyzeEffort
@@ -188,6 +188,7 @@ def _process_text_and_formulas(
effort: Literal["medium", "high", "xhigh"],
local_model_context: HybridLocalModelContext,
images_layout_res: list[list[dict[str, Any]]],
+ page_text_geometries: list[PDFPageTextGeometry | None] | None = None,
) -> list[list[dict[str, Any]]]:
"""在当前窗口内完成 OCR、公式、原生文本及 block 行信息回填。"""
@@ -272,6 +273,7 @@ def _process_text_and_formulas(
parse_mode,
ocr_det_type,
local_model_context,
+ page_text_geometries,
)
@@ -312,6 +314,11 @@ def process_pdf_windows(
raise ValueError("Hybrid processing window PDF page count does not match image count")
images_pil_list = [image_dict["img_pil"] for image_dict in images_list]
_log_processing_window(window, page_count, len(images_pil_list))
+ page_text_geometries: list[PDFPageTextGeometry | None] | None = (
+ [None] * len(window_pages)
+ if not flash_txt_mode and parse_mode == "txt" and effort in {"medium", "high"}
+ else None
+ )
if flash_txt_mode:
# Flash 仅切割当前窗口的外层列表,用于页图释放前原地补充视觉块裁图。
@@ -346,6 +353,7 @@ def process_pdf_windows(
window_pages,
images_list,
effort=effort,
+ page_text_geometries=page_text_geometries,
)
if native_table_summary.total:
native_table_stats = {
@@ -443,6 +451,7 @@ def process_pdf_windows(
effort,
local_model_context,
images_layout_res,
+ page_text_geometries,
)
if effort in {"medium", "high"}:
diff --git a/mineru/model/flash/pdf/pipeline.py b/mineru/model/flash/pdf/pipeline.py
index 3440f2e5..98d226a2 100644
--- a/mineru/model/flash/pdf/pipeline.py
+++ b/mineru/model/flash/pdf/pipeline.py
@@ -349,6 +349,8 @@ def _prepare_page_source(
table_blocks, table_annotation_blocks, claimed_line_indices = _materialize_table_blocks(
source,
candidates,
+ tight_bboxes=tight_bboxes,
+ origins=origins,
)
claimed_line_indices.update(claimed_rule_code_line_indices)
table_bboxes = [block["bbox"] for block in table_blocks]
diff --git a/mineru/model/flash/pdf/table_recovery/candidate.py b/mineru/model/flash/pdf/table_recovery/candidate.py
index 02d08979..5bab43fc 100644
--- a/mineru/model/flash/pdf/table_recovery/candidate.py
+++ b/mineru/model/flash/pdf/table_recovery/candidate.py
@@ -5,6 +5,7 @@ from __future__ import annotations
import html
from bisect import bisect_left, bisect_right
+from collections.abc import Callable
from dataclasses import dataclass
from .....types import BBox
@@ -325,11 +326,22 @@ def build_candidate(
def serialize_candidate_html(candidate: NativeTableCandidate) -> str:
"""把合法候选序列化为稳定、转义且不猜测表头语义的 HTML。"""
+ return serialize_native_table_html(candidate.rows, candidate.cells)
+
+
+def serialize_native_table_html(
+ rows: int,
+ cells: tuple[NativeTableCell, ...],
+ *,
+ render_cell: Callable[[NativeTableCell], str] | None = None,
+) -> str:
+ """按稳定拓扑序列化表格,并允许调用方提供已安全转义的 cell 内容。"""
+
cells_by_row: dict[int, list[NativeTableCell]] = {}
- for cell in candidate.cells:
+ for cell in cells:
cells_by_row.setdefault(cell.row, []).append(cell)
rendered_rows: list[str] = []
- for row_index in range(candidate.rows):
+ for row_index in range(rows):
rendered_cells: list[str] = []
for cell in sorted(cells_by_row.get(row_index, []), key=lambda item: item.col):
attributes = []
@@ -337,8 +349,8 @@ def serialize_candidate_html(candidate: NativeTableCandidate) -> str:
attributes.append(f' rowspan="{cell.rowspan}"')
if cell.colspan > 1:
attributes.append(f' colspan="{cell.colspan}"')
- escaped_content = html.escape(cell.content, quote=False)
- rendered_cells.append(f"<td{''.join(attributes)}>{escaped_content}</td>")
+ content = render_cell(cell) if render_cell is not None else html.escape(cell.content, quote=False)
+ rendered_cells.append(f"<td{''.join(attributes)}>{content}</td>")
rendered_rows.append(f"<tr>{''.join(rendered_cells)}</tr>")
return f"<table><tbody>{''.join(rendered_rows)}</tbody></table>"
@@ -347,4 +359,5 @@ __all__ = [
"GridCellSpec",
"build_candidate",
"serialize_candidate_html",
+ "serialize_native_table_html",
]
diff --git a/mineru/model/flash/pdf/table_recovery/contracts.py b/mineru/model/flash/pdf/table_recovery/contracts.py
index 24853656..d0286740 100644
--- a/mineru/model/flash/pdf/table_recovery/contracts.py
+++ b/mineru/model/flash/pdf/table_recovery/contracts.py
@@ -140,6 +140,7 @@ class NativeTableResult:
rows: int
cols: int
cells: tuple[NativeTableCell, ...]
+ text: NativeTableText
source: NativeTableCandidateSource
confidence: float
diagnostics: tuple[str, ...] = field(default_factory=tuple)
diff --git a/mineru/model/flash/pdf/table_recovery/engine.py b/mineru/model/flash/pdf/table_recovery/engine.py
index 267cdf78..6f79048f 100644
--- a/mineru/model/flash/pdf/table_recovery/engine.py
+++ b/mineru/model/flash/pdf/table_recovery/engine.py
@@ -587,7 +587,7 @@ def recover_native_pdf_table(
evaluation = _evaluate_native_pdf_table(table_input)
selected = evaluation.selected
- if selected is None:
+ if selected is None or evaluation.text is None:
return None
diagnostics = tuple(
[
@@ -606,6 +606,7 @@ def recover_native_pdf_table(
rows=selected.rows,
cols=selected.cols,
cells=selected.cells,
+ text=evaluation.text,
source=selected.source,
confidence=selected.score,
diagnostics=diagnostics,
diff --git a/mineru/model/flash/pdf/table_recovery/text.py b/mineru/model/flash/pdf/table_recovery/text.py
index 53f2a9cb..ffcb7aae 100644
--- a/mineru/model/flash/pdf/table_recovery/text.py
+++ b/mineru/model/flash/pdf/table_recovery/text.py
@@ -193,10 +193,19 @@ def _join_glyph_line(
) -> str:
"""按字符间距重建单行文本,避免在中文字符之间强插空格。"""
+ return "".join(text for text, _source_index in _glyph_line_parts(glyphs, median_height))
+
+
+def _glyph_line_parts(
+ glyphs: list[NativeTableGlyph] | list[_PendingGlyph],
+ median_height: float,
+) -> list[tuple[str, int | None]]:
+ """重建单行文本片段,并保留每个可见片段的原字符索引。"""
+
if not glyphs:
- return ""
+ return []
ordered = sorted(glyphs, key=lambda glyph: (glyph.bbox[0], glyph.bbox[1], glyph.glyph_id))
- parts = [ordered[0].text]
+ parts: list[tuple[str, int | None]] = [(ordered[0].text, ordered[0].source_index)]
previous = ordered[0]
for glyph in ordered[1:]:
gap = glyph.bbox[0] - previous.bbox[2]
@@ -209,11 +218,11 @@ def _join_glyph_line(
and previous_tail.isprintable()
and current_head.isprintable()
)
- if needs_space and not parts[-1].endswith(" "):
- parts.append(" ")
- parts.append(glyph.text)
+ if needs_space and not parts[-1][0].endswith(" "):
+ parts.append((" ", None))
+ parts.append((glyph.text, glyph.source_index))
previous = glyph
- return "".join(parts).strip()
+ return parts
def _tokenize_row(
@@ -299,12 +308,24 @@ def build_cell_text(
) -> str:
"""按视觉行和局部横向顺序重建文本,并将同一单元格内的多行直接拼接。"""
+ return "".join(text for text, _source_index in build_cell_text_parts(glyphs, median_height))
+
+
+def build_cell_text_parts(
+ glyphs: list[NativeTableGlyph],
+ median_height: float,
+) -> list[tuple[str, int | None]]:
+ """按视觉行重建 cell 文本片段,供安全插入字符级语义标签。"""
+
if not glyphs:
- return ""
+ return []
grouped: dict[int, list[NativeTableGlyph]] = {}
for glyph in glyphs:
grouped.setdefault(glyph.visual_row, []).append(glyph)
- return "".join(line for row_index in sorted(grouped) if (line := _join_glyph_line(grouped[row_index], median_height)))
+ parts: list[tuple[str, int | None]] = []
+ for row_index in sorted(grouped):
+ parts.extend(_glyph_line_parts(grouped[row_index], median_height))
+ return parts
def glyph_overlap_ratio(glyph: NativeTableGlyph, bbox: BBox) -> float:
@@ -320,6 +341,7 @@ def glyph_overlap_ratio(glyph: NativeTableGlyph, bbox: BBox) -> float:
__all__ = [
"build_cell_text",
+ "build_cell_text_parts",
"build_native_table_text",
"glyph_overlap_ratio",
]
diff --git a/mineru/model/flash/pdf/table_text_styles.py b/mineru/model/flash/pdf/table_text_styles.py
new file mode 100644
index 00000000..5b3731c4
--- /dev/null
+++ b/mineru/model/flash/pdf/table_text_styles.py
@@ -0,0 +1,281 @@
+# Copyright (c) Opendatalab. All rights reserved.
+
+"""使用 PDF 原生字符几何为高置信表格 HTML 恢复上下标。"""
+
+from __future__ import annotations
+
+import html
+from collections import defaultdict
+from typing import Any
+
+from pdftext.schema import Char
+
+from ....types import BBox
+from .geometry import _bbox_union_many, _coerce_bbox
+from .line_merging import _merge_overlapping_inline_text_clusters
+from .models import _LineItem
+from .native_text import _fill_native_typography
+from .script_geometry import ScriptRole
+from .table_recovery.candidate import serialize_native_table_html
+from .table_recovery.contracts import (
+ NativeTableCell,
+ NativeTableGlyph,
+ NativeTableInput,
+ NativeTableResult,
+ NativeTableRule,
+ NativeTableText,
+)
+from .table_recovery.geometry import page_bbox_to_table_local
+from .table_recovery.text import build_cell_text_parts
+from .text_styles import _fraction_member_indices, _script_line_char_roles
+
+
+def _table_char_map(chars: tuple[Char, ...]) -> dict[int, Char]:
+ """按合法 char_idx 建立页面字符查询表,重复索引保留首项。"""
+
+ output: dict[int, Char] = {}
+ for fallback_index, char in enumerate(chars):
+ char_idx = char.get("char_idx", fallback_index)
+ if isinstance(char_idx, bool) or not isinstance(char_idx, int):
+ continue
+ output.setdefault(char_idx, char)
+ return output
+
+
+def _cell_glyphs(
+ result: NativeTableResult,
+ cell: NativeTableCell,
+) -> list[NativeTableGlyph]:
+ """按 cell 的稳定字符来源收集并恢复视觉行内顺序。"""
+
+ glyph_by_source = {glyph.source_index: glyph for glyph in result.text.glyphs}
+ return sorted(
+ (glyph_by_source[source_index] for source_index in cell.source_char_indices if source_index in glyph_by_source),
+ key=lambda glyph: (glyph.visual_row, glyph.bbox[0], glyph.bbox[1], glyph.glyph_id),
+ )
+
+
+def _cell_visual_lines(
+ glyphs: list[NativeTableGlyph],
+ chars_by_source: dict[int, Char],
+ page_size: tuple[float, float],
+ angle: int,
+) -> list[_LineItem]:
+ """把一个 cell 的 glyph 按 visual row 转换成正文公式分段使用的行。"""
+
+ grouped: dict[int, list[NativeTableGlyph]] = defaultdict(list)
+ for glyph in glyphs:
+ grouped[glyph.visual_row].append(glyph)
+
+ lines: list[_LineItem] = []
+ for visual_row, row_glyphs in sorted(grouped.items()):
+ ordered = sorted(row_glyphs, key=lambda glyph: (glyph.bbox[0], glyph.bbox[1], glyph.glyph_id))
+ chars = [chars_by_source[glyph.source_index] for glyph in ordered if glyph.source_index in chars_by_source]
+ bboxes = [bbox for char in chars if (bbox := _coerce_bbox(char.get("bbox"))) is not None]
+ if not chars or not bboxes:
+ continue
+ line = _LineItem(
+ text="".join(glyph.text for glyph in ordered),
+ bbox=_bbox_union_many(bboxes),
+ angle=angle,
+ source_index=visual_row,
+ chars=chars,
+ visual_row_id=visual_row,
+ )
+ _fill_native_typography(line, page_size)
+ lines.append(line)
+ return lines
+
+
+def _rule_overlaps_boundary(
+ rule_bbox: BBox,
+ boundary_y: float,
+ boundary_left: float,
+ boundary_right: float,
+ tolerance: float,
+) -> bool:
+ """判断局部横线是否与一个逻辑 cell 的水平边界重合。"""
+
+ rule_y = (rule_bbox[1] + rule_bbox[3]) / 2.0
+ if abs(rule_y - boundary_y) > tolerance:
+ return False
+ overlap = min(rule_bbox[2], boundary_right) - max(rule_bbox[0], boundary_left)
+ rule_width = rule_bbox[2] - rule_bbox[0]
+ boundary_width = boundary_right - boundary_left
+ return overlap > 0 and overlap / max(1e-6, min(rule_width, boundary_width)) >= 0.5
+
+
+def _non_grid_fraction_rules(
+ table_input: NativeTableInput,
+ result: NativeTableResult,
+) -> list[NativeTableRule]:
+ """移除与恢复后 cell 边界重合的横线,仅保留可能的分式线。"""
+
+ tolerance = max(0.75, 0.12 * result.text.median_glyph_height)
+ output: list[NativeTableRule] = []
+ for rule in table_input.drawing_lines:
+ if rule.orientation != "horizontal":
+ continue
+ local_bbox = page_bbox_to_table_local(rule.bbox, table_input.table_bbox, table_input.angle)
+ if local_bbox is None:
+ continue
+ is_grid_rule = any(
+ _rule_overlaps_boundary(
+ local_bbox,
+ boundary_y,
+ cell.bbox[0],
+ cell.bbox[2],
+ max(tolerance, rule.width),
+ )
+ for cell in result.cells
+ for boundary_y in (cell.bbox[1], cell.bbox[3])
+ )
+ if not is_grid_rule:
+ output.append(rule)
+ return output
+
+
+def _drop_shifted_word_prefixes(chars: list[dict[str, Any]], roles: list[ScriptRole]) -> None:
+ """拒绝普通字母词仅首字母偏移的弱候选,如 ``-SAT`` 中的 ``S``。"""
+
+ start = 0
+ while start < len(chars):
+ if not str(chars[start].get("char", "")).isalpha():
+ start += 1
+ continue
+ end = start + 1
+ while end < len(chars) and str(chars[end].get("char", "")).isalpha():
+ end += 1
+ if end - start >= 2 and roles[start] != "body" and all(role == "body" for role in roles[start + 1 : end]):
+ roles[start] = "body"
+ start = end
+
+
+def _cell_script_roles(
+ glyphs: list[NativeTableGlyph],
+ chars_by_source: dict[int, Char],
+ page_size: tuple[float, float],
+ angle: int,
+ tight_bboxes: dict[int, BBox],
+ origins: dict[int, tuple[float, float]],
+ fraction_members: set[int],
+) -> dict[int, ScriptRole]:
+ """在 cell 内按正文同款二维公式分段和字符几何返回稳定角色。"""
+
+ lines = _cell_visual_lines(glyphs, chars_by_source, page_size, angle)
+ if not lines:
+ return {}
+ segmented_lines = _merge_overlapping_inline_text_clusters(lines, page_size, [])
+ roles_by_source: dict[int, ScriptRole] = {}
+ for line in segmented_lines:
+ chars, roles, _body_counts, _formula_flags = _script_line_char_roles(
+ line,
+ page_size,
+ tight_bboxes,
+ origins,
+ fraction_members,
+ )
+ _drop_shifted_word_prefixes(chars, roles)
+ for char, role in zip(chars, roles, strict=True):
+ char_idx = char.get("char_idx")
+ if not isinstance(char_idx, int) or role == "body":
+ continue
+ previous = roles_by_source.get(char_idx)
+ roles_by_source[char_idx] = role if previous in {None, role} else "body"
+ return {source_index: role for source_index, role in roles_by_source.items() if role != "body"}
+
+
+def _render_styled_cell(
+ cell: NativeTableCell,
+ glyphs: list[NativeTableGlyph],
+ median_height: float,
+ roles: dict[int, ScriptRole],
+) -> str:
+ """按旧文本重建规则安全插入平坦的 sup/sub 标签。"""
+
+ parts = build_cell_text_parts(glyphs, median_height)
+ if "".join(text for text, _source_index in parts) != cell.content:
+ return html.escape(cell.content, quote=False)
+
+ rendered: list[str] = []
+ active_role: ScriptRole = "body"
+ active_parts: list[str] = []
+
+ def flush() -> None:
+ """提交当前同角色片段,并只生成受信的上下标标签。"""
+
+ nonlocal active_parts
+ if not active_parts:
+ return
+ content = html.escape("".join(active_parts), quote=False)
+ if active_role == "sup":
+ rendered.append(f"<sup>{content}</sup>")
+ elif active_role == "sub":
+ rendered.append(f"<sub>{content}</sub>")
+ else:
+ rendered.append(content)
+ active_parts = []
+
+ for text, source_index in parts:
+ role = roles.get(source_index, "body") if source_index is not None else "body"
+ if role != active_role:
+ flush()
+ active_role = role
+ active_parts.append(text)
+ flush()
+ return "".join(rendered)
+
+
+def render_native_table_html_with_scripts(
+ result: NativeTableResult,
+ table_input: NativeTableInput,
+ tight_bboxes: dict[int, BBox],
+ origins: dict[int, tuple[float, float]],
+) -> str:
+ """为高置信原生表格恢复上下标,证据不足时返回原始 HTML。"""
+
+ if not tight_bboxes or not origins:
+ return result.html
+ if not isinstance(getattr(result, "text", None), NativeTableText):
+ return result.html
+ chars_by_source = _table_char_map(table_input.chars)
+ fraction_rules = _non_grid_fraction_rules(table_input, result)
+ cell_glyphs = {(cell.row, cell.col): _cell_glyphs(result, cell) for cell in result.cells}
+ cell_roles: dict[tuple[int, int], dict[int, ScriptRole]] = {}
+ for cell in result.cells:
+ key = (cell.row, cell.col)
+ glyphs = cell_glyphs[key]
+ cell_chars = [chars_by_source[glyph.source_index] for glyph in glyphs if glyph.source_index in chars_by_source]
+ fraction_members = _fraction_member_indices(
+ table_input.page_size,
+ cell_chars,
+ tight_bboxes,
+ fraction_rules,
+ table_input.angle,
+ )
+ roles = _cell_script_roles(
+ glyphs,
+ chars_by_source,
+ table_input.page_size,
+ table_input.angle,
+ tight_bboxes,
+ origins,
+ fraction_members,
+ )
+ if roles:
+ cell_roles[key] = roles
+ if not cell_roles:
+ return result.html
+ return serialize_native_table_html(
+ result.rows,
+ result.cells,
+ render_cell=lambda cell: _render_styled_cell(
+ cell,
+ cell_glyphs[(cell.row, cell.col)],
+ result.text.median_glyph_height,
+ cell_roles.get((cell.row, cell.col), {}),
+ ),
+ )
+
+
+__all__ = ["render_native_table_html_with_scripts"]
diff --git a/mineru/model/flash/pdf/tables.py b/mineru/model/flash/pdf/tables.py
index 8413f618..970c11af 100644
--- a/mineru/model/flash/pdf/tables.py
+++ b/mineru/model/flash/pdf/tables.py
@@ -20,6 +20,7 @@ from .table_recovery import (
coerce_native_table_rules,
recover_native_pdf_table,
)
+from .table_text_styles import render_native_table_html_with_scripts
from ....utils.text import merge_text_line_contents
from .spatial_text import project_pdf_table_text
from ....types import BBox
@@ -93,28 +94,28 @@ def _recover_native_table_html(
chars: tuple[Char, ...] | None = None,
drawing_lines: tuple[NativeTableRule, ...] | None = None,
rectangles: tuple[NativeTableRectangle, ...] | None = None,
+ tight_bboxes: dict[int, BBox] | None = None,
+ origins: dict[int, tuple[float, float]] | None = None,
) -> str:
"""使用共享原生字符与绘图原语恢复高置信表格 HTML。"""
- result = recover_native_pdf_table(
- NativeTableInput(
- table_bbox=table_bbox,
- page_size=source.page_size,
- angle=angle,
- chars=chars if chars is not None else tuple(source.chars),
- drawing_lines=(
- drawing_lines
- if drawing_lines is not None
- else coerce_native_table_rules(source.drawing_lines)
- ),
- rectangles=(
- rectangles
- if rectangles is not None
- else coerce_native_table_rectangles(source.path_infos)
- ),
- )
+ table_input = NativeTableInput(
+ table_bbox=table_bbox,
+ page_size=source.page_size,
+ angle=angle,
+ chars=chars if chars is not None else tuple(source.chars),
+ drawing_lines=(drawing_lines if drawing_lines is not None else coerce_native_table_rules(source.drawing_lines)),
+ rectangles=(rectangles if rectangles is not None else coerce_native_table_rectangles(source.path_infos)),
+ )
+ result = recover_native_pdf_table(table_input)
+ if result is None:
+ return ""
+ return render_native_table_html_with_scripts(
+ result,
+ table_input,
+ tight_bboxes or {},
+ origins or {},
)
- return result.html if result is not None else ""
def _detect_table_candidates(
@@ -2047,6 +2048,9 @@ def _merge_table_candidate_annotations(
def _materialize_table_blocks(
source: _PageSource,
candidates: list[_TableCandidate],
+ *,
+ tight_bboxes: dict[int, BBox] | None = None,
+ origins: dict[int, tuple[float, float]] | None = None,
) -> tuple[list[dict[str, Any]], list[dict[str, Any]], set[int]]:
"""原子物化表体及其独立注释,仅认领整组成功输出的文本行。"""
@@ -2085,6 +2089,8 @@ def _materialize_table_blocks(
native_chars,
native_rules,
native_rectangles,
+ tight_bboxes,
+ origins,
)
except Exception as exc:
logger.warning(
diff --git a/mineru/model/flash/pdf/text_styles.py b/mineru/model/flash/pdf/text_styles.py
index 29b2866c..e0aa8f78 100644
--- a/mineru/model/flash/pdf/text_styles.py
+++ b/mineru/model/flash/pdf/text_styles.py
@@ -1267,17 +1267,18 @@ def _classify_script_runs(
return roles, body_counts, formula_flags
-def _script_line_payload(
+def _script_line_char_roles(
line: Any,
page_size: tuple[float, float],
tight_bboxes: dict[int, BBox],
origins: dict[int, tuple[float, float]],
fraction_members: set[int],
-) -> PDFTextScriptLine | None:
- """把 Flash 行转换为公式分段后的紧凑上下标 sidecar。"""
+) -> tuple[list[dict[str, Any]], list[ScriptRole], list[int], list[bool]]:
+ """按正文同款公式分段返回原字符及其上下标角色。"""
+
chars = _ordered_line_chars(line)
if not chars:
- return None
+ return [], [], [], []
angle = int(getattr(line, "angle", 0) or 0) % 360
local_chars: list[dict[str, Any]] = []
local_tight_bboxes: dict[int, BBox] = {}
@@ -1321,6 +1322,28 @@ def _script_line_payload(
char_idx = char.get("char_idx")
if isinstance(char_idx, int) and char_idx in fraction_members:
roles[index] = "body"
+ return chars, roles, body_counts, formula_flags
+
+
+def _script_line_payload(
+ line: Any,
+ page_size: tuple[float, float],
+ tight_bboxes: dict[int, BBox],
+ origins: dict[int, tuple[float, float]],
+ fraction_members: set[int],
+) -> PDFTextScriptLine | None:
+ """把 Flash 行转换为公式分段后的紧凑上下标 sidecar。"""
+
+ chars, roles, body_counts, formula_flags = _script_line_char_roles(
+ line,
+ page_size,
+ tight_bboxes,
+ origins,
+ fraction_members,
+ )
+ if not chars:
+ return None
+ angle = int(getattr(line, "angle", 0) or 0) % 360
compact_parts: list[str] = []
compact_roles: list[str] = []
compact_bboxes: list[BBox | None] = []
diff --git a/scripts/render_flash_script_review.py b/scripts/render_flash_script_review.py
index 7a990752..54d612ec 100644
--- a/scripts/render_flash_script_review.py
+++ b/scripts/render_flash_script_review.py
@@ -12,6 +12,7 @@ from collections import Counter, defaultdict, deque
from pathlib import Path
from typing import Any
+from bs4 import BeautifulSoup
from PIL import Image, ImageDraw, ImageFont
from mineru.model.flash.pdf.document import PDFDocument
@@ -176,6 +177,27 @@ def _final_script_runs(
for block_index, block in enumerate(blocks):
block_type = str(block.get("type") or "")
block_bbox = _page_bbox_from_normalized(block.get("bbox"), page_size)
+ block_content = block.get("content")
+ if block_type == "table" and isinstance(block_content, str) and block_content.lstrip().lower().startswith("<table"):
+ soup = BeautifulSoup(block_content, "html.parser")
+ for row_index, row in enumerate(soup.find_all("tr")):
+ for cell_index, cell in enumerate(row.find_all(["td", "th"], recursive=False)):
+ for tag in cell.find_all(["sup", "sub"]):
+ text = tag.get_text()
+ if not _normalized_text(text):
+ continue
+ runs.append(
+ {
+ "block_index": block_index,
+ "block_type": block_type,
+ "block_bbox": list(block_bbox) if block_bbox is not None else None,
+ "role": "superscript" if tag.name == "sup" else "subscript",
+ "text": text,
+ "cell_row": row_index,
+ "cell_col": cell_index,
+ "cell_text": cell.get_text(),
+ }
+ )
def walk(value: Any) -> None:
"""递归遍历 block 的 InlineSpan。"""
@@ -200,7 +222,7 @@ def _final_script_runs(
for child in value:
walk(child)
- walk(block.get("content"))
+ walk(block_content)
return runs
@@ -278,6 +300,8 @@ def _render_crop(
def _build_contact_sheets(
records: list[dict[str, Any]],
staging: Path,
+ *,
+ directory: str = "contact_sheets",
) -> list[str]:
"""按文档把候选 crop 组合成多张联系表。"""
contact_paths = []
@@ -301,7 +325,7 @@ def _build_contact_sheets(
x = (index % CONTACT_COLUMNS) * page_size[0] + 6
y = (index // CONTACT_COLUMNS) * page_size[1] + 6
canvas.paste(crop, (x, y))
- relative = Path("contact_sheets") / (f"{_safe_stem(Path(document_name))}_{sheet_index + 1:02d}.png")
+ relative = Path(directory) / (f"{_safe_stem(Path(document_name))}_{sheet_index + 1:02d}.png")
output = staging / relative
output.parent.mkdir(parents=True, exist_ok=True)
canvas.save(output)
@@ -331,6 +355,7 @@ def _write_review_markdown(records: list[dict[str, Any]], staging: Path) -> Path
[
f"- [ ] `{record['id']}` **{record['role']}** `{record['text']}`",
f" - block: `{record['block_type']}`; angle: `{record['angle']}`; "
+ f"cell: `{record.get('cell_row')},{record.get('cell_col')}`; "
f"formula_region: `{record['formula_region']}`; stable_body_count: `{record['stable_body_count']}`",
f" - previous: {record['previous_line']}",
f" - context: {context}",
@@ -416,7 +441,7 @@ def main() -> None:
"formula_region": False,
"stable_body_count": 0,
"previous_line": "",
- "current_line": final_run["text"],
+ "current_line": final_run.get("cell_text", final_run["text"]),
"next_line": "",
}
)
@@ -448,6 +473,9 @@ def main() -> None:
"previous_line": str(candidate.get("previous_line", "")),
"current_line": str(candidate.get("current_line", final_run["text"])),
"next_line": str(candidate.get("next_line", "")),
+ "cell_row": final_run.get("cell_row"),
+ "cell_col": final_run.get("cell_col"),
+ "cell_text": final_run.get("cell_text"),
"crop": relative_crop.as_posix(),
}
if page_index not in page_images:
@@ -479,6 +507,11 @@ def main() -> None:
}
)
contact_sheets = _build_contact_sheets(records, staging)
+ table_contact_sheets = _build_contact_sheets(
+ [record for record in records if record["block_type"] == "table"],
+ staging,
+ directory="table_contact_sheets",
+ )
review_path = _write_review_markdown(records, staging)
manifest = {
"source_count": len(PDF_PATHS),
@@ -488,6 +521,7 @@ def main() -> None:
"formula_region_count": sum(record["formula_region"] for record in records),
"documents": documents,
"contact_sheets": contact_sheets,
+ "table_contact_sheets": table_contact_sheets,
"records": records,
}
manifest_path = staging / "manifest.json"
diff --git a/tests/fixtures/native_pdf_table_demo_manifest.json b/tests/fixtures/native_pdf_table_demo_manifest.json
index 341a7be3..fb161b64 100644
--- a/tests/fixtures/native_pdf_table_demo_manifest.json
+++ b/tests/fixtures/native_pdf_table_demo_manifest.json
@@ -1,16 +1,16 @@
{
- "schema_version": 3,
- "manifest_version": "2026-08-25-demo-sparse-multiline-v3",
+ "schema_version": 4,
+ "manifest_version": "2026-08-30-native-table-scripts-v4",
"source_root": "demo/pdfs",
"totals": {
- "documents": 14,
- "pages": 104,
- "tables": 44,
- "expected_html": 41,
+ "documents": 15,
+ "pages": 127,
+ "tables": 46,
+ "expected_html": 43,
"expected_projection": 3,
- "tracked_tables": 44,
+ "tracked_tables": 46,
"existing_verified_html": 18,
- "new_verified_html": 23,
+ "new_verified_html": 25,
"fallback_expected": 3
},
"tables": [
@@ -20284,7 +20284,7 @@
"angle": 0,
"expected_output": "html",
"review_status": "target_verified",
- "content_sha256": "3a0bf3295c9c83d4fb3c21851daee9c9c085cdae9ed8a53e51fddec3afe79598",
+ "content_sha256": "989d9e4a1dcc90eb8c78165ebc9c086209fc55ca0a907ec8a5a46af0f41d4a19",
"expected_source": "sparse_multiline",
"rows": 10,
"cols": 7,
@@ -20790,7 +20790,7 @@
"angle": 0,
"expected_output": "html",
"review_status": "existing_verified",
- "content_sha256": "7c5a18775a22d2efac0d940971ba52c713ff75a23cb14208ec6eaa29d8e6137d",
+ "content_sha256": "7ff0031b1507612c021fd20ebedfff7e2d8660afd3faeab3594ca4ac8bc78c05",
"expected_source": "sparse_hybrid",
"rows": 9,
"cols": 3,
@@ -21000,7 +21000,7 @@
"angle": 0,
"expected_output": "html",
"review_status": "existing_verified",
- "content_sha256": "0d2fbc3114bf3bc2f95bc4c17ba97652b73a6b57330d4fa52edf84c10e1918a7",
+ "content_sha256": "0def2755bbba986a464843dff723050bc1f061ccbe57c8028089b93ba20ebbd1",
"expected_source": "vector_grid",
"rows": 9,
"cols": 5,
@@ -21532,7 +21532,7 @@
"angle": 0,
"expected_output": "html",
"review_status": "target_verified",
- "content_sha256": "0f8c19e5bd163d8d3c37297233aff208ab07de4e696561361585ea42f5beabf6",
+ "content_sha256": "4f0d10bfc866afd6189fa66079db4b692b215363097a4fd3bbc9c4f47f72cb9d",
"expected_source": "sparse_multiline",
"rows": 14,
"cols": 6,
@@ -22133,7 +22133,7 @@
"angle": 0,
"expected_output": "html",
"review_status": "existing_verified",
- "content_sha256": "db10d2560f690f11b585c9550cdf554cf057004c7c89d177aeccf3c17b8f90e4",
+ "content_sha256": "0efbe72e79f6b953806ddb6d8be1fc2100247d29ba1ba02838ee3b652f634c73",
"expected_source": "sparse_hybrid",
"rows": 12,
"cols": 10,
@@ -22958,7 +22958,7 @@
"angle": 0,
"expected_output": "html",
"review_status": "target_verified",
- "content_sha256": "5bfbf71ba768d8c6c737f164415e3eba3b6d50545e7ae4b2d8898b1f07d740e3",
+ "content_sha256": "164625c7493a2afb27821b0cada6575a9843df5ed3995e372be7368c7f69cc05",
"expected_source": "sparse_multiline",
"rows": 11,
"cols": 3,
@@ -23210,7 +23210,7 @@
"angle": 0,
"expected_output": "html",
"review_status": "target_verified",
- "content_sha256": "a854fb5444b20805d67e0aa3474cdfdae51fd15b63d22c3f184804b006adabfb",
+ "content_sha256": "8b5a16fb797203354d52dc5323f7ef31b643ef6e396b35f67b0f3d7330a29471",
"expected_source": "sparse_multiline",
"rows": 5,
"cols": 2,
@@ -23301,7 +23301,7 @@
"angle": 0,
"expected_output": "html",
"review_status": "target_verified",
- "content_sha256": "44f1e274c6ab834af4237bca93d3eca833ce3cb074af33aec4a12d8e92d266a1",
+ "content_sha256": "dd085ccd303c047fe52d2a9e01a3a3fc9afec41170fc6a4905e7b91ce26b5b0c",
"expected_source": "sparse_multiline",
"rows": 5,
"cols": 5,
@@ -23497,7 +23497,7 @@
"angle": 0,
"expected_output": "html",
"review_status": "target_verified",
- "content_sha256": "4d7449a59e0a30fe190e3db2b8eb19d6cbd32218ddf1c0b51039d1027e55e2ef",
+ "content_sha256": "33caad5439c6c58882477e813cb69e1c6b3845d3cab02722eda2f9be1306021c",
"expected_source": "sparse_multiline",
"rows": 9,
"cols": 5,
@@ -23832,7 +23832,7 @@
"angle": 0,
"expected_output": "html",
"review_status": "existing_verified",
- "content_sha256": "f25432428d565b97dd16ec037a6234a6f9e74985fdfd92bc97e10450edfdc6a2",
+ "content_sha256": "41c63a73de3e715148d184436e09ccfc656a65c06869f1ba4579014748aa040c",
"expected_source": "sparse_hybrid",
"rows": 15,
"cols": 3,
@@ -24588,7 +24588,7 @@
"angle": 0,
"expected_output": "html",
"review_status": "existing_verified",
- "content_sha256": "1605146e64ef7be920fc778076bf4abdb744abf3123148327054bd3b6195ec9f",
+ "content_sha256": "47f40b9d7ec55a5daaa315419e23fba80efca37922bf20e6317cf1d9973b799c",
"expected_source": "sparse_hybrid",
"rows": 3,
"cols": 6,
@@ -25211,7 +25211,7 @@
"angle": 0,
"expected_output": "html",
"review_status": "target_verified",
- "content_sha256": "d0c635e80dc56d2f6ac809dbb8ebe7e990eaeacab0c77db7c602955ac1361c3c",
+ "content_sha256": "9470c6774f0ed9f16f63b07a7c8f55ca5e6f2cde08038a0ad4dccb93e54d64c6",
"expected_source": "sparse_multiline",
"rows": 7,
"cols": 5,
@@ -25810,6 +25810,1196 @@
"review_status": "fallback_expected",
"content_sha256": "9bac22d6ce15b6a8b6d97e95c5ffe76f6ea188a068698b8df17c70c5ea276b71",
"rejection_reason": "overlapping_formula_rows"
+ },
+ {
+ "file": "中文论文2.pdf",
+ "page_index": 1,
+ "table_index": 0,
+ "bbox": [
+ 0.095,
+ 0.478,
+ 0.905,
+ 0.911
+ ],
+ "angle": 0,
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "content_sha256": "e572309d4f3045c68cf66d3d28b356723dd7edd0bcff680ed6c28e9b2b979c56",
+ "expected_source": "vector_grid",
+ "rows": 19,
+ "cols": 6,
+ "span_signature": [],
+ "cell_truth": [
+ {
+ "row": 0,
+ "col": 0,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "基准名称"
+ },
+ {
+ "row": 0,
+ "col": 1,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "发布时间"
+ },
+ {
+ "row": 0,
+ "col": 2,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "发布人/机构"
+ },
+ {
+ "row": 0,
+ "col": 3,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "规模"
+ },
+ {
+ "row": 0,
+ "col": 4,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "评价方面"
+ },
+ {
+ "row": 0,
+ "col": 5,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "语种数"
+ },
+ {
+ "row": 1,
+ "col": 0,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "DecaNLP"
+ },
+ {
+ "row": 1,
+ "col": 1,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "2018年"
+ },
+ {
+ "row": 1,
+ "col": 2,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "McCann等"
+ },
+ {
+ "row": 1,
+ "col": 3,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "10个任务"
+ },
+ {
+ "row": 1,
+ "col": 4,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "NLU"
+ },
+ {
+ "row": 1,
+ "col": 5,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "1"
+ },
+ {
+ "row": 2,
+ "col": 0,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "GLUE"
+ },
+ {
+ "row": 2,
+ "col": 1,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "2018年"
+ },
+ {
+ "row": 2,
+ "col": 2,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "纽约大学等"
+ },
+ {
+ "row": 2,
+ "col": 3,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "9个任务"
+ },
+ {
+ "row": 2,
+ "col": 4,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "NLU"
+ },
+ {
+ "row": 2,
+ "col": 5,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "1"
+ },
+ {
+ "row": 3,
+ "col": 0,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "SuperGLUE"
+ },
+ {
+ "row": 3,
+ "col": 1,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "2019年"
+ },
+ {
+ "row": 3,
+ "col": 2,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "纽约大学等"
+ },
+ {
+ "row": 3,
+ "col": 3,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "8个任务"
+ },
+ {
+ "row": 3,
+ "col": 4,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "NLU"
+ },
+ {
+ "row": 3,
+ "col": 5,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "1"
+ },
+ {
+ "row": 4,
+ "col": 0,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "XTREME"
+ },
+ {
+ "row": 4,
+ "col": 1,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "2020年"
+ },
+ {
+ "row": 4,
+ "col": 2,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "卡耐基梅隆大学等"
+ },
+ {
+ "row": 4,
+ "col": 3,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "9个任务"
+ },
+ {
+ "row": 4,
+ "col": 4,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "NLU"
+ },
+ {
+ "row": 4,
+ "col": 5,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "40"
+ },
+ {
+ "row": 5,
+ "col": 0,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "XGLUE"
+ },
+ {
+ "row": 5,
+ "col": 1,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "2020年"
+ },
+ {
+ "row": 5,
+ "col": 2,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "微软"
+ },
+ {
+ "row": 5,
+ "col": 3,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "11个任务"
+ },
+ {
+ "row": 5,
+ "col": 4,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "NLU"
+ },
+ {
+ "row": 5,
+ "col": 5,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "19"
+ },
+ {
+ "row": 6,
+ "col": 0,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "CLUE"
+ },
+ {
+ "row": 6,
+ "col": 1,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "2020年"
+ },
+ {
+ "row": 6,
+ "col": 2,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "CLUE团队"
+ },
+ {
+ "row": 6,
+ "col": 3,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "9个任务"
+ },
+ {
+ "row": 6,
+ "col": 4,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "NLU"
+ },
+ {
+ "row": 6,
+ "col": 5,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "1"
+ },
+ {
+ "row": 7,
+ "col": 0,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "GLGE"
+ },
+ {
+ "row": 7,
+ "col": 1,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "2020年"
+ },
+ {
+ "row": 7,
+ "col": 2,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "四川大学等"
+ },
+ {
+ "row": 7,
+ "col": 3,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "4个任务"
+ },
+ {
+ "row": 7,
+ "col": 4,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "NLG"
+ },
+ {
+ "row": 7,
+ "col": 5,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "1"
+ },
+ {
+ "row": 8,
+ "col": 0,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "GEM"
+ },
+ {
+ "row": 8,
+ "col": 1,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "2021年"
+ },
+ {
+ "row": 8,
+ "col": 2,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "卡耐基梅隆大学等"
+ },
+ {
+ "row": 8,
+ "col": 3,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "11个数据集"
+ },
+ {
+ "row": 8,
+ "col": 4,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "NLG"
+ },
+ {
+ "row": 8,
+ "col": 5,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "18"
+ },
+ {
+ "row": 9,
+ "col": 0,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "CUGE"
+ },
+ {
+ "row": 9,
+ "col": 1,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "2021年"
+ },
+ {
+ "row": 9,
+ "col": 2,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "清华大学等"
+ },
+ {
+ "row": 9,
+ "col": 3,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "21个数据集"
+ },
+ {
+ "row": 9,
+ "col": 4,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "NLU、NLG"
+ },
+ {
+ "row": 9,
+ "col": 5,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "1"
+ },
+ {
+ "row": 10,
+ "col": 0,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "EleuHthaerrnAesIsLM"
+ },
+ {
+ "row": 10,
+ "col": 1,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "2021年"
+ },
+ {
+ "row": 10,
+ "col": 2,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "EleutherAI"
+ },
+ {
+ "row": 10,
+ "col": 3,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "200余个数据集"
+ },
+ {
+ "row": 10,
+ "col": 4,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "NLU、NLG"
+ },
+ {
+ "row": 10,
+ "col": 5,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "-"
+ },
+ {
+ "row": 11,
+ "col": 0,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "BIG-bench"
+ },
+ {
+ "row": 11,
+ "col": 1,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "2022年"
+ },
+ {
+ "row": 11,
+ "col": 2,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "谷歌"
+ },
+ {
+ "row": 11,
+ "col": 3,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "200余个数据集"
+ },
+ {
+ "row": 11,
+ "col": 4,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "逻辑能力、数学伦能理力道、德代码理解能力、"
+ },
+ {
+ "row": 11,
+ "col": 5,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "-"
+ },
+ {
+ "row": 12,
+ "col": 0,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "MT-Bench"
+ },
+ {
+ "row": 12,
+ "col": 1,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "2023年"
+ },
+ {
+ "row": 12,
+ "col": 2,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "伯克利大学等"
+ },
+ {
+ "row": 12,
+ "col": 3,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "80个样例"
+ },
+ {
+ "row": 12,
+ "col": 4,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "与人类偏好对齐程度"
+ },
+ {
+ "row": 12,
+ "col": 5,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "1"
+ },
+ {
+ "row": 13,
+ "col": 0,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "ChatbotArena"
+ },
+ {
+ "row": 13,
+ "col": 1,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "2023年"
+ },
+ {
+ "row": 13,
+ "col": 2,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "伯克利大学等"
+ },
+ {
+ "row": 13,
+ "col": 3,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "-"
+ },
+ {
+ "row": 13,
+ "col": 4,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "与人类偏好对齐程度"
+ },
+ {
+ "row": 13,
+ "col": 5,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "-"
+ },
+ {
+ "row": 14,
+ "col": 0,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "SuperCLUE-Open"
+ },
+ {
+ "row": 14,
+ "col": 1,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "2023年"
+ },
+ {
+ "row": 14,
+ "col": 2,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "CLUE团队"
+ },
+ {
+ "row": 14,
+ "col": 3,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "1.2k个样例"
+ },
+ {
+ "row": 14,
+ "col": 4,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "与人类偏好对齐程度"
+ },
+ {
+ "row": 14,
+ "col": 5,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "1"
+ },
+ {
+ "row": 15,
+ "col": 0,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "C-EVAL"
+ },
+ {
+ "row": 15,
+ "col": 1,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "2023年"
+ },
+ {
+ "row": 15,
+ "col": 2,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "上海交通大学等"
+ },
+ {
+ "row": 15,
+ "col": 3,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "13948个样例"
+ },
+ {
+ "row": 15,
+ "col": 4,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "知识运用与推理能力"
+ },
+ {
+ "row": 15,
+ "col": 5,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "1"
+ },
+ {
+ "row": 16,
+ "col": 0,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "SAFETYPROMPTS"
+ },
+ {
+ "row": 16,
+ "col": 1,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "2023年"
+ },
+ {
+ "row": 16,
+ "col": 2,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "清华大学等"
+ },
+ {
+ "row": 16,
+ "col": 3,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "100k个样例"
+ },
+ {
+ "row": 16,
+ "col": 4,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "安全性"
+ },
+ {
+ "row": 16,
+ "col": 5,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "1"
+ },
+ {
+ "row": 17,
+ "col": 0,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "LLMEVAL"
+ },
+ {
+ "row": 17,
+ "col": 1,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "2023年"
+ },
+ {
+ "row": 17,
+ "col": 2,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "复旦大学等"
+ },
+ {
+ "row": 17,
+ "col": 3,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "933个样例"
+ },
+ {
+ "row": 17,
+ "col": 4,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "正确性、流畅性、信息量、逻辑性、无害性等"
+ },
+ {
+ "row": 17,
+ "col": 5,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "1"
+ },
+ {
+ "row": 18,
+ "col": 0,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "TriviaQA"
+ },
+ {
+ "row": 18,
+ "col": 1,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "2017年"
+ },
+ {
+ "row": 18,
+ "col": 2,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "华盛顿大学等"
+ },
+ {
+ "row": 18,
+ "col": 3,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "95k个样例"
+ },
+ {
+ "row": 18,
+ "col": 4,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "知识运用能力"
+ },
+ {
+ "row": 18,
+ "col": 5,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "1"
+ }
+ ]
+ },
+ {
+ "file": "中文论文2.pdf",
+ "page_index": 2,
+ "table_index": 0,
+ "bbox": [
+ 0.095,
+ 0.075,
+ 0.905,
+ 0.297
+ ],
+ "angle": 0,
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "content_sha256": "917b8da9b7ef5ab009647fe8c2c9c69c82b7638b43c5f9fc0efb009e2da45da3",
+ "expected_source": "vector_grid",
+ "rows": 9,
+ "cols": 6,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 1,
+ 6
+ ]
+ ],
+ "cell_truth": [
+ {
+ "row": 0,
+ "col": 0,
+ "rowspan": 1,
+ "colspan": 6,
+ "text": "续表"
+ },
+ {
+ "row": 1,
+ "col": 0,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "基准名称"
+ },
+ {
+ "row": 1,
+ "col": 1,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "发布时间"
+ },
+ {
+ "row": 1,
+ "col": 2,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "发布人/机构"
+ },
+ {
+ "row": 1,
+ "col": 3,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "规模"
+ },
+ {
+ "row": 1,
+ "col": 4,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "评价方面"
+ },
+ {
+ "row": 1,
+ "col": 5,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "语种数"
+ },
+ {
+ "row": 2,
+ "col": 0,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "OpenBookQA"
+ },
+ {
+ "row": 2,
+ "col": 1,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "2018年"
+ },
+ {
+ "row": 2,
+ "col": 2,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "艾伦人工智能研究所等"
+ },
+ {
+ "row": 2,
+ "col": 3,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "约6k个样例"
+ },
+ {
+ "row": 2,
+ "col": 4,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "知识运用能力"
+ },
+ {
+ "row": 2,
+ "col": 5,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "1"
+ },
+ {
+ "row": 3,
+ "col": 0,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "GSM8k"
+ },
+ {
+ "row": 3,
+ "col": 1,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "2021年"
+ },
+ {
+ "row": 3,
+ "col": 2,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "OpenAI等"
+ },
+ {
+ "row": 3,
+ "col": 3,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "8.5k个样例"
+ },
+ {
+ "row": 3,
+ "col": 4,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "数学推理能力"
+ },
+ {
+ "row": 3,
+ "col": 5,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "1"
+ },
+ {
+ "row": 4,
+ "col": 0,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "HaluEval"
+ },
+ {
+ "row": 4,
+ "col": 1,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "2023年"
+ },
+ {
+ "row": 4,
+ "col": 2,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "人民大学等"
+ },
+ {
+ "row": 4,
+ "col": 3,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "35k个样例"
+ },
+ {
+ "row": 4,
+ "col": 4,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "检测幻觉能力"
+ },
+ {
+ "row": 4,
+ "col": 5,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "1"
+ },
+ {
+ "row": 5,
+ "col": 0,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "MMLU"
+ },
+ {
+ "row": 5,
+ "col": 1,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "2021年"
+ },
+ {
+ "row": 5,
+ "col": 2,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "伯克利大学等"
+ },
+ {
+ "row": 5,
+ "col": 3,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "57个数据集"
+ },
+ {
+ "row": 5,
+ "col": 4,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "知识运用与问题解决能力"
+ },
+ {
+ "row": 5,
+ "col": 5,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "1"
+ },
+ {
+ "row": 6,
+ "col": 0,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "HellaSwag"
+ },
+ {
+ "row": 6,
+ "col": 1,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "2019年"
+ },
+ {
+ "row": 6,
+ "col": 2,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "华盛顿大学"
+ },
+ {
+ "row": 6,
+ "col": 3,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "70k个样例"
+ },
+ {
+ "row": 6,
+ "col": 4,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "常识推理能力"
+ },
+ {
+ "row": 6,
+ "col": 5,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "1"
+ },
+ {
+ "row": 7,
+ "col": 0,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "HumanEval"
+ },
+ {
+ "row": 7,
+ "col": 1,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "2021年"
+ },
+ {
+ "row": 7,
+ "col": 2,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "OpenAI等"
+ },
+ {
+ "row": 7,
+ "col": 3,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "164个样例"
+ },
+ {
+ "row": 7,
+ "col": 4,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "代码生成能力"
+ },
+ {
+ "row": 7,
+ "col": 5,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "-"
+ },
+ {
+ "row": 8,
+ "col": 0,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "DROP"
+ },
+ {
+ "row": 8,
+ "col": 1,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "2019年"
+ },
+ {
+ "row": 8,
+ "col": 2,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "加利福尼亚大学等"
+ },
+ {
+ "row": 8,
+ "col": 3,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "96k个样例"
+ },
+ {
+ "row": 8,
+ "col": 4,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "阅读理解和数值推理能力"
+ },
+ {
+ "row": 8,
+ "col": 5,
+ "rowspan": 1,
+ "colspan": 1,
+ "text": "1"
+ }
+ ]
}
]
}
diff --git a/tests/fixtures/native_pdf_table_script_truth.json b/tests/fixtures/native_pdf_table_script_truth.json
new file mode 100644
index 00000000..248d26ca
--- /dev/null
+++ b/tests/fixtures/native_pdf_table_script_truth.json
@@ -0,0 +1,1062 @@
+{
+ "schema_version": 1,
+ "matching": [
+ "file",
+ "page_index",
+ "table_index",
+ "row",
+ "col",
+ "text",
+ "style"
+ ],
+ "precision_policy": "actual_runs_must_be_subset_of_truth; required_runs_must_be_emitted",
+ "runs": [
+ {
+ "file": "demo1.pdf",
+ "page_index": 8,
+ "table_index": 0,
+ "row": 0,
+ "col": 2,
+ "cell_text": "Rainfalla (mm)",
+ "text": "a",
+ "style": "superscript"
+ },
+ {
+ "file": "demo1.pdf",
+ "page_index": 8,
+ "table_index": 0,
+ "row": 1,
+ "col": 5,
+ "cell_text": "Total flowreduction (%)b",
+ "text": "b",
+ "style": "superscript"
+ },
+ {
+ "file": "demo1.pdf",
+ "page_index": 8,
+ "table_index": 0,
+ "row": 1,
+ "col": 6,
+ "cell_text": "Low flowreduction (%)c",
+ "text": "c",
+ "style": "superscript"
+ },
+ {
+ "file": "demo1.pdf",
+ "page_index": 8,
+ "table_index": 0,
+ "row": 3,
+ "col": 5,
+ "cell_text": "62d",
+ "text": "d",
+ "style": "superscript"
+ },
+ {
+ "file": "demo2.pdf",
+ "page_index": 3,
+ "table_index": 0,
+ "row": 3,
+ "col": 0,
+ "cell_text": "γc",
+ "text": "c",
+ "style": "subscript"
+ },
+ {
+ "file": "demo2.pdf",
+ "page_index": 3,
+ "table_index": 0,
+ "row": 3,
+ "col": 1,
+ "cell_text": "Strength of grouping by color similarity 1",
+ "text": "1",
+ "style": "superscript"
+ },
+ {
+ "file": "demo2.pdf",
+ "page_index": 3,
+ "table_index": 0,
+ "row": 4,
+ "col": 0,
+ "cell_text": "γg",
+ "text": "g",
+ "style": "subscript"
+ },
+ {
+ "file": "demo2.pdf",
+ "page_index": 3,
+ "table_index": 0,
+ "row": 4,
+ "col": 1,
+ "cell_text": "Strength of grouping by proximity 1",
+ "text": "1",
+ "style": "superscript"
+ },
+ {
+ "file": "demo2.pdf",
+ "page_index": 3,
+ "table_index": 0,
+ "row": 6,
+ "col": 0,
+ "cell_text": "γt",
+ "text": "t",
+ "style": "subscript"
+ },
+ {
+ "file": "demo2.pdf",
+ "page_index": 4,
+ "table_index": 0,
+ "row": 0,
+ "col": 2,
+ "cell_text": "MDE/s1",
+ "text": "1",
+ "style": "superscript"
+ },
+ {
+ "file": "demo2.pdf",
+ "page_index": 4,
+ "table_index": 0,
+ "row": 0,
+ "col": 3,
+ "cell_text": "FPS2",
+ "text": "2",
+ "style": "superscript"
+ },
+ {
+ "file": "demo2.pdf",
+ "page_index": 4,
+ "table_index": 0,
+ "row": 0,
+ "col": 4,
+ "cell_text": "Error3",
+ "text": "3",
+ "style": "superscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 4,
+ "table_index": 0,
+ "row": 1,
+ "col": 3,
+ "cell_text": "ALLd",
+ "text": "d",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 4,
+ "table_index": 0,
+ "row": 6,
+ "col": 0,
+ "cell_text": "TAPASBASE",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 4,
+ "table_index": 0,
+ "row": 7,
+ "col": 0,
+ "cell_text": "TABLEFORMERBASE",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 4,
+ "table_index": 0,
+ "row": 8,
+ "col": 0,
+ "cell_text": "TAPASLARGE",
+ "text": "LARGE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 4,
+ "table_index": 0,
+ "row": 9,
+ "col": 0,
+ "cell_text": "TABLEFORMERLARGE",
+ "text": "LARGE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 4,
+ "table_index": 0,
+ "row": 10,
+ "col": 0,
+ "cell_text": "TAPASBASE inter",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 4,
+ "table_index": 0,
+ "row": 11,
+ "col": 0,
+ "cell_text": "TABLEFORMERBASE inter",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 4,
+ "table_index": 0,
+ "row": 12,
+ "col": 0,
+ "cell_text": "TAPASLARGE inter",
+ "text": "LARGE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 4,
+ "table_index": 0,
+ "row": 13,
+ "col": 0,
+ "cell_text": "TABLEFORMERLARGE inter",
+ "text": "LARGE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 5,
+ "table_index": 0,
+ "row": 1,
+ "col": 3,
+ "cell_text": "testsimple",
+ "text": "simple",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 5,
+ "table_index": 0,
+ "row": 1,
+ "col": 4,
+ "cell_text": "testcomplex",
+ "text": "complex",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 5,
+ "table_index": 0,
+ "row": 1,
+ "col": 5,
+ "cell_text": "testsmall",
+ "text": "small",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 5,
+ "table_index": 0,
+ "row": 1,
+ "col": 7,
+ "cell_text": "testsimple",
+ "text": "simple",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 5,
+ "table_index": 0,
+ "row": 1,
+ "col": 8,
+ "cell_text": "testcomplex",
+ "text": "complex",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 5,
+ "table_index": 0,
+ "row": 1,
+ "col": 9,
+ "cell_text": "testsmall",
+ "text": "small",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 5,
+ "table_index": 0,
+ "row": 4,
+ "col": 0,
+ "cell_text": "TAPASBASE",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 5,
+ "table_index": 0,
+ "row": 5,
+ "col": 0,
+ "cell_text": "TABLEFORMERBASE",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 5,
+ "table_index": 0,
+ "row": 6,
+ "col": 0,
+ "cell_text": "TAPASLARGE",
+ "text": "LARGE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 5,
+ "table_index": 0,
+ "row": 7,
+ "col": 0,
+ "cell_text": "TABLEFORMERLARGE",
+ "text": "LARGE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 5,
+ "table_index": 0,
+ "row": 8,
+ "col": 0,
+ "cell_text": "TAPASBASE inter",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 5,
+ "table_index": 0,
+ "row": 9,
+ "col": 0,
+ "cell_text": "TABLEFORMERBASE inter",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 5,
+ "table_index": 0,
+ "row": 10,
+ "col": 0,
+ "cell_text": "TAPASLARGE inter",
+ "text": "LARGE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 5,
+ "table_index": 0,
+ "row": 11,
+ "col": 0,
+ "cell_text": "TABLEFORMERLARGE inter",
+ "text": "LARGE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 5,
+ "table_index": 1,
+ "row": 3,
+ "col": 0,
+ "cell_text": "TAPASBASE",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 5,
+ "table_index": 1,
+ "row": 4,
+ "col": 0,
+ "cell_text": "TABLEFORMERBASE",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 5,
+ "table_index": 1,
+ "row": 5,
+ "col": 0,
+ "cell_text": "TAPASLARGE",
+ "text": "LARGE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 5,
+ "table_index": 1,
+ "row": 6,
+ "col": 0,
+ "cell_text": "TABLEFORMERLARGE",
+ "text": "LARGE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 5,
+ "table_index": 1,
+ "row": 7,
+ "col": 0,
+ "cell_text": "TAPASBASE inter-sqa",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 5,
+ "table_index": 1,
+ "row": 8,
+ "col": 0,
+ "cell_text": "TABLEFORMERBASE inter-sqa",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 5,
+ "table_index": 1,
+ "row": 9,
+ "col": 0,
+ "cell_text": "TAPASLARGE inter-sqa",
+ "text": "LARGE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 5,
+ "table_index": 1,
+ "row": 10,
+ "col": 0,
+ "cell_text": "TABLEFORMERLARGE inter-sqa",
+ "text": "LARGE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 6,
+ "table_index": 0,
+ "row": 1,
+ "col": 0,
+ "cell_text": "TAPASBASE",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 6,
+ "table_index": 0,
+ "row": 2,
+ "col": 0,
+ "cell_text": "TABLEFORMERBASE",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 6,
+ "table_index": 0,
+ "row": 3,
+ "col": 0,
+ "cell_text": "TAPASLARGE",
+ "text": "LARGE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 6,
+ "table_index": 0,
+ "row": 4,
+ "col": 0,
+ "cell_text": "TABLEFORMERLARGE",
+ "text": "LARGE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 6,
+ "table_index": 1,
+ "row": 1,
+ "col": 0,
+ "cell_text": "TAPASBASE",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 6,
+ "table_index": 1,
+ "row": 2,
+ "col": 0,
+ "cell_text": "TAPASBASE-SAT",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 6,
+ "table_index": 1,
+ "row": 3,
+ "col": 0,
+ "cell_text": "TABLEFORMERBASE-SO",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 6,
+ "table_index": 1,
+ "row": 4,
+ "col": 0,
+ "cell_text": "TABLEFORMERBASE",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 7,
+ "table_index": 0,
+ "row": 2,
+ "col": 0,
+ "cell_text": "TAPASBASE",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 7,
+ "table_index": 0,
+ "row": 3,
+ "col": 0,
+ "cell_text": "TAPASBASE 1p",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 7,
+ "table_index": 0,
+ "row": 4,
+ "col": 0,
+ "cell_text": "TAPASBASE 2p",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 7,
+ "table_index": 0,
+ "row": 5,
+ "col": 0,
+ "cell_text": "TAPASBASE 4p",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 7,
+ "table_index": 0,
+ "row": 6,
+ "col": 0,
+ "cell_text": "TAPASBASE 8p",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 7,
+ "table_index": 0,
+ "row": 7,
+ "col": 0,
+ "cell_text": "TAPASBASE 16p",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 7,
+ "table_index": 0,
+ "row": 8,
+ "col": 0,
+ "cell_text": "TABLEFORMERBASE",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 7,
+ "table_index": 1,
+ "row": 1,
+ "col": 0,
+ "cell_text": "TABLEFORMERBASE",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "mixed_elements_pages_03_06.pdf",
+ "page_index": 2,
+ "table_index": 0,
+ "row": 0,
+ "col": 1,
+ "cell_text": "T0, K",
+ "text": "0",
+ "style": "subscript"
+ },
+ {
+ "file": "mixed_elements_pages_03_06.pdf",
+ "page_index": 2,
+ "table_index": 0,
+ "row": 0,
+ "col": 3,
+ "cell_text": "N(EF), eV-1 cm-3",
+ "text": "-1",
+ "style": "superscript"
+ },
+ {
+ "file": "mixed_elements_pages_03_06.pdf",
+ "page_index": 2,
+ "table_index": 0,
+ "row": 0,
+ "col": 3,
+ "cell_text": "N(EF), eV-1 cm-3",
+ "text": "-3",
+ "style": "superscript"
+ },
+ {
+ "file": "mixed_elements_pages_03_06.pdf",
+ "page_index": 2,
+ "table_index": 0,
+ "row": 0,
+ "col": 3,
+ "cell_text": "N(EF), eV-1 cm-3",
+ "text": "F",
+ "style": "subscript"
+ },
+ {
+ "file": "mixed_elements_pages_03_06.pdf",
+ "page_index": 2,
+ "table_index": 0,
+ "row": 1,
+ "col": 2,
+ "cell_text": "9.2 × 103",
+ "text": "3",
+ "style": "superscript"
+ },
+ {
+ "file": "mixed_elements_pages_03_06.pdf",
+ "page_index": 2,
+ "table_index": 0,
+ "row": 1,
+ "col": 5,
+ "cell_text": "1.28 × 10-4",
+ "text": "-4",
+ "style": "superscript"
+ },
+ {
+ "file": "mixed_elements_pages_03_06.pdf",
+ "page_index": 2,
+ "table_index": 0,
+ "row": 2,
+ "col": 2,
+ "cell_text": "7.2 × 104",
+ "text": "4",
+ "style": "superscript"
+ },
+ {
+ "file": "mixed_elements_pages_03_06.pdf",
+ "page_index": 2,
+ "table_index": 0,
+ "row": 2,
+ "col": 5,
+ "cell_text": "2.72 × 10-5",
+ "text": "-5",
+ "style": "superscript"
+ },
+ {
+ "file": "mixed_elements_pages_11_15.pdf",
+ "page_index": 3,
+ "table_index": 0,
+ "row": 2,
+ "col": 1,
+ "cell_text": "26.5 ± 4.3a",
+ "text": "a",
+ "style": "superscript"
+ },
+ {
+ "file": "mixed_elements_pages_11_15.pdf",
+ "page_index": 3,
+ "table_index": 0,
+ "row": 3,
+ "col": 1,
+ "cell_text": "25.5 ± 3.9a",
+ "text": "a",
+ "style": "superscript"
+ },
+ {
+ "file": "mixed_elements_pages_11_15.pdf",
+ "page_index": 3,
+ "table_index": 0,
+ "row": 4,
+ "col": 1,
+ "cell_text": "27.0 ± 3.0a",
+ "text": "a",
+ "style": "superscript"
+ },
+ {
+ "file": "mixed_elements_pages_11_15.pdf",
+ "page_index": 3,
+ "table_index": 0,
+ "row": 4,
+ "col": 2,
+ "cell_text": "39.5 ± 4.2a",
+ "text": "a",
+ "style": "superscript"
+ },
+ {
+ "file": "mixed_elements_pages_11_15.pdf",
+ "page_index": 3,
+ "table_index": 0,
+ "row": 5,
+ "col": 1,
+ "cell_text": "6.4 ± 3.0a,b,c",
+ "text": "a,b,c",
+ "style": "superscript"
+ },
+ {
+ "file": "mixed_elements_pages_11_15.pdf",
+ "page_index": 3,
+ "table_index": 0,
+ "row": 6,
+ "col": 1,
+ "cell_text": "6.1 ± 2.8a,b,d",
+ "text": "a,b,d",
+ "style": "superscript"
+ },
+ {
+ "file": "mixed_elements_pages_11_15.pdf",
+ "page_index": 3,
+ "table_index": 0,
+ "row": 6,
+ "col": 2,
+ "cell_text": "40.7 ± 4.1a",
+ "text": "a",
+ "style": "superscript"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 48,
+ "table_index": 0,
+ "row": 1,
+ "col": 6,
+ "cell_text": "浓度限值(mg/Nm3)",
+ "text": "3",
+ "style": "superscript"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 49,
+ "table_index": 0,
+ "row": 1,
+ "col": 6,
+ "cell_text": "浓度限值(mg/Nm3)",
+ "text": "3",
+ "style": "superscript"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 50,
+ "table_index": 0,
+ "row": 1,
+ "col": 6,
+ "cell_text": "浓度限值(mg/Nm3)",
+ "text": "3",
+ "style": "superscript"
+ }
+ ],
+ "required_runs": [
+ {
+ "file": "demo2.pdf",
+ "page_index": 3,
+ "table_index": 0,
+ "row": 3,
+ "col": 0,
+ "cell_text": "γc",
+ "text": "c",
+ "style": "subscript"
+ },
+ {
+ "file": "demo2.pdf",
+ "page_index": 3,
+ "table_index": 0,
+ "row": 4,
+ "col": 0,
+ "cell_text": "γg",
+ "text": "g",
+ "style": "subscript"
+ },
+ {
+ "file": "demo2.pdf",
+ "page_index": 3,
+ "table_index": 0,
+ "row": 6,
+ "col": 0,
+ "cell_text": "γt",
+ "text": "t",
+ "style": "subscript"
+ },
+ {
+ "file": "demo2.pdf",
+ "page_index": 4,
+ "table_index": 0,
+ "row": 0,
+ "col": 2,
+ "cell_text": "MDE/s1",
+ "text": "1",
+ "style": "superscript"
+ },
+ {
+ "file": "demo2.pdf",
+ "page_index": 4,
+ "table_index": 0,
+ "row": 0,
+ "col": 3,
+ "cell_text": "FPS2",
+ "text": "2",
+ "style": "superscript"
+ },
+ {
+ "file": "demo2.pdf",
+ "page_index": 4,
+ "table_index": 0,
+ "row": 0,
+ "col": 4,
+ "cell_text": "Error3",
+ "text": "3",
+ "style": "superscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 4,
+ "table_index": 0,
+ "row": 6,
+ "col": 0,
+ "cell_text": "TAPASBASE",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 4,
+ "table_index": 0,
+ "row": 8,
+ "col": 0,
+ "cell_text": "TAPASLARGE",
+ "text": "LARGE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 5,
+ "table_index": 0,
+ "row": 4,
+ "col": 0,
+ "cell_text": "TAPASBASE",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 5,
+ "table_index": 0,
+ "row": 6,
+ "col": 0,
+ "cell_text": "TAPASLARGE",
+ "text": "LARGE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 5,
+ "table_index": 1,
+ "row": 3,
+ "col": 0,
+ "cell_text": "TAPASBASE",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 5,
+ "table_index": 1,
+ "row": 5,
+ "col": 0,
+ "cell_text": "TAPASLARGE",
+ "text": "LARGE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 6,
+ "table_index": 0,
+ "row": 1,
+ "col": 0,
+ "cell_text": "TAPASBASE",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 6,
+ "table_index": 0,
+ "row": 3,
+ "col": 0,
+ "cell_text": "TAPASLARGE",
+ "text": "LARGE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 6,
+ "table_index": 1,
+ "row": 1,
+ "col": 0,
+ "cell_text": "TAPASBASE",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 7,
+ "table_index": 0,
+ "row": 2,
+ "col": 0,
+ "cell_text": "TAPASBASE",
+ "text": "BASE",
+ "style": "subscript"
+ },
+ {
+ "file": "mixed_elements_pages_03_06.pdf",
+ "page_index": 2,
+ "table_index": 0,
+ "row": 0,
+ "col": 1,
+ "cell_text": "T0, K",
+ "text": "0",
+ "style": "subscript"
+ },
+ {
+ "file": "mixed_elements_pages_03_06.pdf",
+ "page_index": 2,
+ "table_index": 0,
+ "row": 0,
+ "col": 3,
+ "cell_text": "N(EF), eV-1 cm-3",
+ "text": "-1",
+ "style": "superscript"
+ },
+ {
+ "file": "mixed_elements_pages_03_06.pdf",
+ "page_index": 2,
+ "table_index": 0,
+ "row": 0,
+ "col": 3,
+ "cell_text": "N(EF), eV-1 cm-3",
+ "text": "F",
+ "style": "subscript"
+ },
+ {
+ "file": "mixed_elements_pages_03_06.pdf",
+ "page_index": 2,
+ "table_index": 0,
+ "row": 1,
+ "col": 2,
+ "cell_text": "9.2 × 103",
+ "text": "3",
+ "style": "superscript"
+ },
+ {
+ "file": "mixed_elements_pages_03_06.pdf",
+ "page_index": 2,
+ "table_index": 0,
+ "row": 1,
+ "col": 5,
+ "cell_text": "1.28 × 10-4",
+ "text": "-4",
+ "style": "superscript"
+ },
+ {
+ "file": "mixed_elements_pages_11_15.pdf",
+ "page_index": 3,
+ "table_index": 0,
+ "row": 5,
+ "col": 1,
+ "cell_text": "6.4 ± 3.0a,b,c",
+ "text": "a,b,c",
+ "style": "superscript"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 48,
+ "table_index": 0,
+ "row": 1,
+ "col": 6,
+ "cell_text": "浓度限值(mg/Nm3)",
+ "text": "3",
+ "style": "superscript"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 49,
+ "table_index": 0,
+ "row": 1,
+ "col": 6,
+ "cell_text": "浓度限值(mg/Nm3)",
+ "text": "3",
+ "style": "superscript"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 50,
+ "table_index": 0,
+ "row": 1,
+ "col": 6,
+ "cell_text": "浓度限值(mg/Nm3)",
+ "text": "3",
+ "style": "superscript"
+ }
+ ],
+ "forbidden_runs": [
+ {
+ "file": "demo3.pdf",
+ "page_index": 6,
+ "table_index": 1,
+ "cell_text": "TAPASBASE-SAT",
+ "text": "S",
+ "style": "subscript"
+ },
+ {
+ "file": "demo3.pdf",
+ "page_index": 6,
+ "table_index": 1,
+ "cell_text": "TABLEFORMERBASE-SO",
+ "text": "S",
+ "style": "subscript"
+ }
+ ],
+ "forbidden_plain_cells": [
+ "最小值",
+ "最大值",
+ "序号",
+ "7,059.94",
+ "2,845.04"
+ ]
+}
diff --git a/tests/unittest/test_flash_pdf_pipeline.py b/tests/unittest/test_flash_pdf_pipeline.py
index f4db81c3..fad2a34c 100644
--- a/tests/unittest/test_flash_pdf_pipeline.py
+++ b/tests/unittest/test_flash_pdf_pipeline.py
@@ -73,6 +73,7 @@ def test_prepare_page_materializes_table_against_original_semantic_lines(
def fake_materialize(
materialization_source: models._PageSource,
candidates: list[models._TableCandidate],
+ **_kwargs: object,
) -> tuple[list[dict[str, object]], list[dict[str, object]], set[int]]:
"""记录表格物化阶段可见的来源行。"""
diff --git a/tests/unittest/test_flash_pdf_samples.py b/tests/unittest/test_flash_pdf_samples.py
index 7e68b092..9946edda 100644
--- a/tests/unittest/test_flash_pdf_samples.py
+++ b/tests/unittest/test_flash_pdf_samples.py
@@ -173,7 +173,8 @@ def _visible_content(value: Any) -> str:
content = value.get("content") if isinstance(value, dict) else value
if isinstance(content, str) and content.lstrip().lower().startswith("<table"):
- content = BeautifulSoup(content, "html.parser").get_text(" ")
+ soup = BeautifulSoup(content, "html.parser")
+ content = " ".join(cell.get_text() for cell in soup.find_all(["td", "th"]))
return visible_content(content)
@@ -181,7 +182,7 @@ def _html_table_rows(content: str) -> list[tuple[str, ...]]:
"""读取原生结构恢复输出的 HTML 表格行与单元格纯文本。"""
soup = BeautifulSoup(content, "html.parser")
- return [tuple(cell.get_text(" ") for cell in row.find_all(["td", "th"], recursive=False)) for row in soup.find_all("tr")]
+ return [tuple(cell.get_text() for cell in row.find_all(["td", "th"], recursive=False)) for row in soup.find_all("tr")]
def _normalized_content_probe(text: str) -> str:
@@ -838,8 +839,9 @@ def test_demo3_keeps_tables_and_covers_every_native_source_line() -> None:
page10_first_reference = next(
block for block in model_list[9] if _visible_content(block).startswith("Xiang Deng, Huan Sun")
)
+ table4_text = _visible_content(page7_table4)
assert all(
- marker in page7_table4["content"]
+ marker in table4_text
for marker in (
"Model",
"TAPASBASE",
diff --git a/tests/unittest/test_native_pdf_table_pipeline.py b/tests/unittest/test_native_pdf_table_pipeline.py
index 1be8172d..44d395b2 100644
--- a/tests/unittest/test_native_pdf_table_pipeline.py
+++ b/tests/unittest/test_native_pdf_table_pipeline.py
@@ -16,6 +16,7 @@ from mineru.backend.analysis.pdf import tables as pdf_tables
from mineru.backend.analysis.pdf import window as pdf_window
from mineru.model.flash.pdf import models as flash_models
from mineru.model.flash.pdf import tables as flash_tables
+from mineru.model.flash.pdf.document import PDFPageTextGeometry
from mineru.types import RAW_FORMULA_NUMBER, BlockType
@@ -25,6 +26,11 @@ def _build_native_pdf_page(*, width: float = 100.0, height: float = 100.0) -> Ma
page = MagicMock()
page.size = (width, height)
page.get_chars.return_value = []
+ page.get_chars_with_geometry.return_value = PDFPageTextGeometry(
+ chars=[],
+ tight_bboxes={},
+ origins={},
+ )
page.get_drawing_lines.return_value = []
page.get_path_infos.return_value = []
return page
@@ -181,7 +187,7 @@ def test_medium_native_table_priority_accepts_html_and_removes_internal_text_and
assert table_input.table_bbox == pytest.approx((10.0, 40.0, 90.0, 160.0))
assert table_input.page_size == (100.0, 200.0)
assert table_input.angle == 0
- page.get_chars.assert_called_once_with()
+ page.get_chars_with_geometry.assert_called_once_with()
page.get_drawing_lines.assert_called_once_with()
page.get_path_infos.assert_called_once_with()
@@ -227,12 +233,13 @@ def test_hybrid_native_table_priority_falls_back_for_complex_content(
recover.assert_not_called()
-def test_high_native_table_priority_falls_back_for_formula_content(
+def test_high_native_table_priority_ignores_layout_formula_and_removes_duplicates(
monkeypatch: pytest.MonkeyPatch,
) -> None:
- """验证 High 将表内公式视为复杂内容并且不调用原生规则。"""
+ """验证 High 不采信 layout 公式框,并在原生命中后移除重复对象。"""
- recover = MagicMock()
+ html = "<table><tbody><tr><td>T</td></tr></tbody></table>"
+ recover = MagicMock(return_value=SimpleNamespace(html=html, source="vector_grid", confidence=1.0))
monkeypatch.setattr(pdf_tables, "recover_native_pdf_table", recover)
table_block = {"type": BlockType.TABLE, "bbox": [0.1, 0.1, 0.9, 0.9], "angle": 0}
equation_block = {"type": BlockType.EQUATION, "bbox": [0.2, 0.2, 0.4, 0.4]}
@@ -250,13 +257,19 @@ def test_high_native_table_priority_falls_back_for_formula_content(
finally:
image.close()
- assert page_blocks == [table_block, equation_block]
- assert layout_res == [{"label": "inline_formula", "bbox": [20, 20, 40, 40]}]
- assert summary == pdf_tables._NativeTablePrioritySummary(total=1, complex_fallbacks=1)
+ assert table_block["content"] == html
+ assert page_blocks == [table_block]
+ assert layout_res == []
+ assert summary == pdf_tables._NativeTablePrioritySummary(
+ total=1,
+ accepted=1,
+ removed_formula_blocks=1,
+ removed_formula_layout_items=1,
+ )
vlm_blocks, accepted_tables = pdf_tables._split_native_high_table_blocks([page_blocks])
- assert vlm_blocks == [page_blocks]
- assert accepted_tables == [[]]
- recover.assert_not_called()
+ assert vlm_blocks == [[]]
+ assert accepted_tables == [[table_block]]
+ recover.assert_called_once()
def test_hybrid_native_table_priority_falls_back_for_rotated_table(
@@ -327,7 +340,7 @@ def test_hybrid_native_table_priority_keeps_none_and_exception_fallbacks(
errors=1,
)
assert recover.call_count == 2
- page.get_chars.assert_called_once_with()
+ page.get_chars_with_geometry.assert_called_once_with()
def test_medium_table_tasks_skip_native_html_and_keep_model_fallback() -> None:
@@ -454,6 +467,7 @@ def test_high_txt_window_excludes_native_table_from_vlm(
hybrid_model = MagicMock()
hybrid_model.layout_model.batch_predict.return_value = layout_results
vlm_predictor = MagicMock()
+ cached_geometry = PDFPageTextGeometry(chars=[], tight_bboxes={}, origins={})
def fake_native_priority(
model_list: list[list[dict[str, object]]],
@@ -462,10 +476,13 @@ def test_high_txt_window_excludes_native_table_from_vlm(
_images_list: object,
*,
effort: object,
+ page_text_geometries: object,
) -> object:
"""只命中首个表格,构造同页混合短路场景。"""
assert effort == "high"
+ assert isinstance(page_text_geometries, list)
+ page_text_geometries[0] = cached_geometry
model_list[0][0]["content"] = native_html
return pdf_tables._NativeTablePrioritySummary(total=2, accepted=1, rejected=1)
@@ -485,9 +502,12 @@ def test_high_txt_window_excludes_native_table_from_vlm(
_effort: object,
_local_model_context: object,
_images_layout_res: object,
+ _page_text_geometries: object,
) -> list[list[dict[str, object]]]:
"""跳过与本测试无关的正文和公式回填。"""
+ assert isinstance(_page_text_geometries, list)
+ assert _page_text_geometries[0] is cached_geometry
return model_list
vlm_predictor.batch_extract_with_layout.side_effect = fake_high_extract
diff --git a/tests/unittest/test_native_pdf_table_scripts.py b/tests/unittest/test_native_pdf_table_scripts.py
new file mode 100644
index 00000000..f3a3a578
--- /dev/null
+++ b/tests/unittest/test_native_pdf_table_scripts.py
@@ -0,0 +1,356 @@
+# Copyright (c) Opendatalab. All rights reserved.
+"""验证原生 PDF 表格上下标的几何识别与安全 HTML 序列化。"""
+
+from __future__ import annotations
+
+import json
+from collections import defaultdict
+from pathlib import Path
+
+from bs4 import BeautifulSoup
+from pdftext.schema import Bbox, Char
+import pytest
+
+from mineru.model.flash.pdf.geometry import _rotate_bbox_from_upright
+from mineru.model.flash.pdf.document import PDFDocument
+from mineru.model.flash.pdf.table_recovery import (
+ NativeTableInput,
+ coerce_native_table_rectangles,
+ coerce_native_table_rules,
+ recover_native_pdf_table,
+)
+from mineru.model.flash.pdf.table_recovery.candidate import serialize_native_table_html
+from mineru.model.flash.pdf.table_recovery.contracts import (
+ NativeTableCell,
+ NativeTableGlyph,
+ NativeTableResult,
+ NativeTableRule,
+ NativeTableText,
+ NativeTableTextRow,
+)
+from mineru.model.flash.pdf.table_text_styles import (
+ _non_grid_fraction_rules,
+ render_native_table_html_with_scripts,
+)
+
+
+_PROJECT_ROOT = Path(__file__).parents[2]
+_SCRIPT_TRUTH_PATH = _PROJECT_ROOT / "tests" / "fixtures" / "native_pdf_table_script_truth.json"
+
+
+def _char(
+ text: str,
+ index: int,
+ bbox: tuple[float, float, float, float],
+) -> Char:
+ """构造带稳定来源索引的合成 PDF 字符。"""
+
+ return {
+ "char": text,
+ "char_idx": index,
+ "bbox": Bbox(list(bbox)),
+ "rotation": 0.0,
+ "font": {},
+ }
+
+
+def _origin_from_upright(
+ origin: tuple[float, float],
+ page_size: tuple[float, float],
+ angle: int,
+) -> tuple[float, float]:
+ """把正向 origin 逆变换到合成页面坐标。"""
+
+ x, y = origin
+ page_width, page_height = page_size
+ if angle == 270:
+ return y, page_height - x
+ if angle == 90:
+ return page_width - y, x
+ if angle == 180:
+ return page_width - x, page_height - y
+ return origin
+
+
+def _result(
+ content: str,
+ glyphs: tuple[NativeTableGlyph, ...],
+ *,
+ cells: tuple[NativeTableCell, ...] | None = None,
+) -> NativeTableResult:
+ """构造单格高置信恢复结果,并保持默认 HTML 与纯文本一致。"""
+
+ resolved_cells = cells or (
+ NativeTableCell(
+ row=0,
+ col=0,
+ rowspan=1,
+ colspan=1,
+ bbox=(0.0, 0.0, 60.0, 60.0),
+ content=content,
+ source_char_indices=tuple(glyph.source_index for glyph in glyphs),
+ ),
+ )
+ text = NativeTableText(
+ glyphs=glyphs,
+ rows=tuple(
+ NativeTableTextRow(
+ row_index=row_index,
+ bbox=(
+ min(glyph.bbox[0] for glyph in row_glyphs),
+ min(glyph.bbox[1] for glyph in row_glyphs),
+ max(glyph.bbox[2] for glyph in row_glyphs),
+ max(glyph.bbox[3] for glyph in row_glyphs),
+ ),
+ tokens=(),
+ glyph_ids=tuple(glyph.glyph_id for glyph in row_glyphs),
+ )
+ for row_index in sorted({glyph.visual_row for glyph in glyphs})
+ if (row_glyphs := [glyph for glyph in glyphs if glyph.visual_row == row_index])
+ ),
+ median_glyph_width=8.0,
+ median_glyph_height=10.0,
+ )
+ return NativeTableResult(
+ html=serialize_native_table_html(1, resolved_cells),
+ rows=1,
+ cols=max(1, len(resolved_cells)),
+ cells=resolved_cells,
+ text=text,
+ source="vector_grid",
+ confidence=1.0,
+ )
+
+
+def test_table_script_serialization_escapes_text_and_marks_superscript() -> None:
+ """验证原始尖括号保持转义,只有可信数字被包装为上标。"""
+
+ chars = (
+ _char("<", 0, (5.0, 40.0, 9.0, 50.0)),
+ _char("A", 1, (10.0, 40.0, 20.0, 50.0)),
+ _char("2", 2, (20.0, 34.0, 26.0, 40.0)),
+ )
+ glyphs = tuple(
+ NativeTableGlyph(index, index, char["char"], tuple(char["bbox"]), 0) # type: ignore[arg-type]
+ for index, char in enumerate(chars)
+ )
+ result = _result("<A2", glyphs)
+ table_input = NativeTableInput((0.0, 0.0, 60.0, 60.0), (60.0, 60.0), 0, chars)
+
+ styled = render_native_table_html_with_scripts(
+ result,
+ table_input,
+ {0: (5.0, 40.0, 9.0, 50.0), 1: (10.0, 40.0, 20.0, 50.0), 2: (20.0, 34.0, 26.0, 40.0)},
+ {0: (5.0, 49.0), 1: (10.0, 49.0), 2: (20.0, 40.0)},
+ )
+
+ assert "&lt;A<sup>2</sup>" in styled
+ assert BeautifulSoup(styled, "html.parser").get_text() == "<A2"
+
+
[email protected]("angle", [0, 90, 180, 270])
+def test_table_script_geometry_uses_upright_coordinates(angle: int) -> None:
+ """验证四种标准方向下 cell loose/tight/origin 同步正向化。"""
+
+ page_size = (100.0, 120.0)
+ local_bboxes = ((10.0, 40.0, 20.0, 50.0), (20.0, 34.0, 26.0, 40.0))
+ local_origins = ((10.0, 49.0), (20.0, 40.0))
+ page_bboxes = tuple(_rotate_bbox_from_upright(bbox, page_size, angle) for bbox in local_bboxes)
+ page_origins = tuple(_origin_from_upright(origin, page_size, angle) for origin in local_origins)
+ chars = tuple(_char(text, index, page_bboxes[index]) for index, text in enumerate("A2"))
+ glyphs = (
+ NativeTableGlyph(0, 0, "A", local_bboxes[0], 0),
+ NativeTableGlyph(1, 1, "2", local_bboxes[1], 0),
+ )
+ result = _result("A2", glyphs)
+ table_input = NativeTableInput((0.0, 0.0, *page_size), page_size, angle, chars)
+
+ styled = render_native_table_html_with_scripts(
+ result,
+ table_input,
+ dict(enumerate(page_bboxes)),
+ dict(enumerate(page_origins)),
+ )
+
+ assert BeautifulSoup(styled, "html.parser").find("sup").get_text() == "2" # type: ignore[union-attr]
+
+
+def test_table_fraction_region_stays_plain() -> None:
+ """验证 cell 内短分数线会拒识其上下叠排字符。"""
+
+ chars = (
+ _char("x", 0, (10.0, 40.0, 20.0, 50.0)),
+ _char("1", 1, (22.0, 32.0, 30.0, 40.0)),
+ _char("M", 2, (22.0, 44.0, 30.0, 52.0)),
+ )
+ glyphs = (
+ NativeTableGlyph(0, 0, "x", (10.0, 40.0, 20.0, 50.0), 0),
+ NativeTableGlyph(1, 1, "1", (22.0, 32.0, 30.0, 40.0), 0),
+ NativeTableGlyph(2, 2, "M", (22.0, 44.0, 30.0, 52.0), 1),
+ )
+ result = _result("x1M", glyphs)
+ table_input = NativeTableInput(
+ (0.0, 0.0, 60.0, 60.0),
+ (60.0, 60.0),
+ 0,
+ chars,
+ drawing_lines=(NativeTableRule((21.0, 41.0, 31.0, 42.0), 1.0, "horizontal"),),
+ )
+
+ styled = render_native_table_html_with_scripts(
+ result,
+ table_input,
+ {0: (10.0, 40.0, 20.0, 50.0), 1: (22.0, 32.0, 30.0, 40.0), 2: (22.0, 44.0, 30.0, 52.0)},
+ {0: (10.0, 49.0), 1: (22.0, 40.0), 2: (22.0, 52.0)},
+ )
+
+ assert "<sup>" not in styled and "<sub>" not in styled
+ assert BeautifulSoup(styled, "html.parser").get_text() == "x1M"
+
+
+def test_table_grid_boundary_is_not_a_fraction_rule() -> None:
+ """验证与任一逻辑 cell 边界重合的横线不会进入分式检测。"""
+
+ glyphs = (NativeTableGlyph(0, 0, "A", (5.0, 5.0, 15.0, 15.0), 0),)
+ cells = (
+ NativeTableCell(0, 0, 1, 1, (0.0, 0.0, 30.0, 30.0), "A", (0,)),
+ NativeTableCell(0, 1, 1, 1, (30.0, 0.0, 60.0, 30.0), "", ()),
+ )
+ result = _result("A", glyphs, cells=cells)
+ grid_rule = NativeTableRule((0.0, 29.5, 60.0, 30.5), 1.0, "horizontal")
+ fraction_rule = NativeTableRule((5.0, 15.0, 15.0, 16.0), 1.0, "horizontal")
+ table_input = NativeTableInput(
+ (0.0, 0.0, 60.0, 60.0),
+ (60.0, 60.0),
+ 0,
+ (_char("A", 0, (5.0, 5.0, 15.0, 15.0)),),
+ drawing_lines=(grid_rule, fraction_rule),
+ )
+
+ assert _non_grid_fraction_rules(table_input, result) == [fraction_rule]
+
+
+def test_table_missing_extended_geometry_keeps_original_html() -> None:
+ """验证缺少 tight/origin 时不根据 loose bbox 猜测上下标。"""
+
+ chars = (_char("A", 0, (10.0, 40.0, 20.0, 50.0)),)
+ glyphs = (NativeTableGlyph(0, 0, "A", (10.0, 40.0, 20.0, 50.0), 0),)
+ result = _result("A", glyphs)
+ table_input = NativeTableInput((0.0, 0.0, 60.0, 60.0), (60.0, 60.0), 0, chars)
+
+ assert render_native_table_html_with_scripts(result, table_input, {}, {}) == result.html
+
+
+def _manifest_table_input(
+ document: PDFDocument,
+ entry: dict[str, object],
+ *,
+ cross_page_manifest: bool,
+) -> tuple[NativeTableInput, dict[int, tuple[float, float, float, float]], dict[int, tuple[float, float]]]:
+ """按 manifest bbox 构造表格输入,并返回同页扩展字符几何。"""
+
+ page_index = int(entry["page_index"]) # type: ignore[arg-type]
+ page_size = document.page_size(page_index)
+ geometry = document.get_page_chars_with_geometry(page_index)
+ raw_bbox = entry["bbox"] # type: ignore[assignment]
+ if cross_page_manifest:
+ production_size = int(page_size[0]), int(page_size[1])
+ bbox = tuple(
+ float(raw_bbox[index]) * (production_size[0] if index % 2 == 0 else production_size[1]) # type: ignore[index]
+ for index in range(4)
+ )
+ else:
+ bbox = tuple(
+ float(raw_bbox[index]) * (page_size[0] if index % 2 == 0 else page_size[1]) # type: ignore[index]
+ for index in range(4)
+ )
+ return (
+ NativeTableInput(
+ table_bbox=bbox, # type: ignore[arg-type]
+ page_size=page_size,
+ angle=int(entry.get("angle", 0) or 0),
+ chars=tuple(geometry.chars),
+ drawing_lines=coerce_native_table_rules(document.get_page_drawing_lines(page_index)),
+ rectangles=coerce_native_table_rectangles(document.get_page_path_infos(page_index)),
+ ),
+ geometry.tight_bboxes,
+ geometry.origins,
+ )
+
+
+def _real_manifest_script_runs() -> tuple[set[tuple[object, ...]], set[str]]:
+ """运行两套仓库表格语料,并收集最终 cell 上下标及带样式 cell。"""
+
+ fields = ("file", "page_index", "table_index", "row", "col", "text", "style")
+ actual: set[tuple[object, ...]] = set()
+ styled_cell_texts: set[str] = set()
+ manifest_specs = (
+ ("tests/fixtures/native_pdf_table_demo_manifest.json", "demo/pdfs", "tables", False),
+ (
+ "tests/fixtures/native_pdf_table_cross_page_manifest.json",
+ "tests/unittest/pdfs/native_pdf_tables",
+ "entries",
+ True,
+ ),
+ )
+ for manifest_path, source_root, key, cross_page_manifest in manifest_specs:
+ manifest = json.loads((_PROJECT_ROOT / manifest_path).read_text(encoding="utf-8"))
+ by_file: dict[str, list[dict[str, object]]] = defaultdict(list)
+ for entry in manifest[key]:
+ if entry.get("expected_output") == "html":
+ by_file[str(entry["file"])].append(entry)
+ for filename, entries in by_file.items():
+ with PDFDocument(str(_PROJECT_ROOT / source_root / filename)) as document:
+ for entry in entries:
+ table_input, tight_bboxes, origins = _manifest_table_input(
+ document,
+ entry,
+ cross_page_manifest=cross_page_manifest,
+ )
+ result = recover_native_pdf_table(table_input)
+ assert result is not None
+ styled = render_native_table_html_with_scripts(result, table_input, tight_bboxes, origins)
+ html_cells = BeautifulSoup(styled, "html.parser").find_all("td")
+ assert len(html_cells) == len(result.cells)
+ for source_cell, html_cell in zip(result.cells, html_cells, strict=True):
+ tags = html_cell.find_all(["sup", "sub"])
+ if tags:
+ styled_cell_texts.add(source_cell.content)
+ for tag in tags:
+ record = {
+ "file": filename,
+ "page_index": int(entry["page_index"]),
+ "table_index": int(entry["table_index"]),
+ "row": source_cell.row,
+ "col": source_cell.col,
+ "text": tag.get_text(),
+ "style": "superscript" if tag.name == "sup" else "subscript",
+ }
+ actual.add(tuple(record[field] for field in fields))
+ return actual, styled_cell_texts
+
+
+def test_real_native_table_scripts_are_precision_gated() -> None:
+ """验证全部实际输出属于人工真值,必召回项存在且强制负例保持纯文本。"""
+
+ truth = json.loads(_SCRIPT_TRUTH_PATH.read_text(encoding="utf-8"))
+ fields = tuple(truth["matching"])
+ expected = {tuple(record[field] for field in fields) for record in truth["runs"]}
+ required = {tuple(record[field] for field in fields) for record in truth["required_runs"]}
+ actual, styled_cell_texts = _real_manifest_script_runs()
+
+ assert len(expected) == 77
+ assert actual <= expected
+ assert required <= actual
+ assert not styled_cell_texts.intersection(truth["forbidden_plain_cells"])
+ assert all(
+ not any(
+ actual_record[0] == forbidden["file"]
+ and actual_record[1] == forbidden["page_index"]
+ and actual_record[2] == forbidden["table_index"]
+ and actual_record[5] == forbidden["text"]
+ and actual_record[6] == forbidden["style"]
+ for actual_record in actual
+ )
+ for forbidden in truth["forbidden_runs"]
+ )
diff --git a/tests/unittest/test_pdf_analyze_block_content.py b/tests/unittest/test_pdf_analyze_block_content.py
index 65460533..2e8d2739 100644
--- a/tests/unittest/test_pdf_analyze_block_content.py
+++ b/tests/unittest/test_pdf_analyze_block_content.py
@@ -177,6 +177,7 @@ def test_doc_analyze_converts_vlm_results_before_downstream_processing(
_effort: object,
_hybrid_model: object,
_images_layout_res: object,
+ _page_text_geometries: object,
) -> list[list[dict[str, object]]]:
"""原样返回窗口结果,并在后处理入口校验精确容器类型。"""
assert type(window_model_list) is list