Skip to content

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

feat: add native PDF table structure recovery

myhloli140ed0cea5fd
diff --git a/mineru/backend/analysis/pdf/tables.py b/mineru/backend/analysis/pdf/tables.py
index b55697da..621a4efd 100644
--- a/mineru/backend/analysis/pdf/tables.py
+++ b/mineru/backend/analysis/pdf/tables.py
@@ -19,6 +19,14 @@ from mineru.utils.bbox_utils import (
calculate_overlap_area_in_bbox1_area_ratio,
normalize_to_int_bbox,
)
+from mineru.utils.native_pdf_table import (
+ NativeTableInput,
+ NativeTableRectangle,
+ NativeTableRule,
+ coerce_native_table_rectangles,
+ coerce_native_table_rules,
+ recover_native_pdf_table,
+)
from mineru.utils.ocr_utils import mask_formula_regions_for_ocr_det
from mineru.utils.pdf_document import PDFPage, get_lines_from_chars
from mineru.utils.pdf_text_styles import PDFTextLinkLine, PDFTextStyleLine
@@ -584,7 +592,7 @@ def _fill_low_table_contents(
parse_mode: Literal["txt", "ocr"],
local_model_context: HybridLocalModelContext,
) -> None:
- """为 low 表格回填空间投影纯文本,单表失败时保留空内容并继续。"""
+ """为 Low 表格回填高置信原生 HTML 或空间投影文本。"""
table_entries: list[dict[str, Any]] = []
for page_idx, page_model_list in enumerate(model_list):
table_idx = 0
@@ -609,6 +617,8 @@ def _fill_low_table_contents(
if parse_mode == "txt":
page_chars_cache: dict[int, list[Any]] = {}
+ page_rules_cache: dict[int, tuple[NativeTableRule, ...]] = {}
+ page_rectangles_cache: dict[int, tuple[NativeTableRectangle, ...]] = {}
for table_entry in table_entries:
page_idx = table_entry["page_idx"]
table_idx = table_entry["table_idx"]
@@ -624,11 +634,64 @@ def _fill_low_table_contents(
raise ValueError("invalid table bbox")
if page_idx not in page_chars_cache:
page_chars_cache[page_idx] = pdf_page.get_chars()
- table_block["content"] = project_pdf_table_text(
- page_chars_cache[page_idx],
- table_bbox,
- table_block.get("angle", 0),
- )
+ if page_idx not in page_rules_cache:
+ try:
+ page_rules_cache[page_idx] = coerce_native_table_rules(
+ pdf_page.get_drawing_lines()
+ )
+ except Exception as exc:
+ logger.warning(
+ "Hybrid low native table drawing extraction failed: "
+ f"page_idx={page_idx}, error={exc}"
+ )
+ page_rules_cache[page_idx] = ()
+ if page_idx not in page_rectangles_cache:
+ try:
+ page_rectangles_cache[page_idx] = (
+ coerce_native_table_rectangles(
+ pdf_page.get_path_infos()
+ )
+ )
+ except Exception as exc:
+ logger.warning(
+ "Hybrid low native table path extraction failed: "
+ f"page_idx={page_idx}, error={exc}"
+ )
+ page_rectangles_cache[page_idx] = ()
+
+ native_result = None
+ try:
+ # PDFPage 字符和 drawing 已应用页面字典旋转;Low 的文本角度仍是
+ # PDF 字符内禀角,因此仅在原生结构恢复入口补回页面旋转。
+ native_angle = (
+ _normalize_visual_block_angle(
+ table_block.get("angle", 0)
+ )
+ + pdf_page.rotation
+ ) % 360
+ native_result = recover_native_pdf_table(
+ NativeTableInput(
+ table_bbox=table_bbox,
+ page_size=(float(page_width), float(page_height)),
+ angle=native_angle,
+ chars=tuple(page_chars_cache[page_idx]),
+ drawing_lines=page_rules_cache[page_idx],
+ rectangles=page_rectangles_cache[page_idx],
+ )
+ )
+ except Exception as exc:
+ logger.warning(
+ "Hybrid low native table recovery failed and fell back to projection: "
+ f"page_idx={page_idx}, table_idx={table_idx}, error={exc}"
+ )
+ if native_result is not None:
+ table_block["content"] = native_result.html
+ else:
+ table_block["content"] = project_pdf_table_text(
+ page_chars_cache[page_idx],
+ table_bbox,
+ table_block.get("angle", 0),
+ )
if not table_block["content"]:
logger.warning(
"Hybrid low table text is empty: "
diff --git a/mineru/model/flash/native_pdf/tables.py b/mineru/model/flash/native_pdf/tables.py
index f0681c9f..06bc5d88 100644
--- a/mineru/model/flash/native_pdf/tables.py
+++ b/mineru/model/flash/native_pdf/tables.py
@@ -10,7 +10,16 @@ import unicodedata
from typing import Any, Literal
from loguru import logger
-
+from pdftext.schema import Char
+
+from mineru.utils.native_pdf_table import (
+ NativeTableInput,
+ NativeTableRectangle,
+ NativeTableRule,
+ coerce_native_table_rectangles,
+ coerce_native_table_rules,
+ recover_native_pdf_table,
+)
from mineru.utils.text_utils import merge_text_line_contents
from mineru.utils.spatial_text import project_pdf_table_text
from mineru.types import BBox
@@ -77,6 +86,37 @@ _FILLED_GRID_MIN_PAGE_WIDTH_RATIO = 0.12
_FILLED_GRID_MIN_PAGE_HEIGHT_RATIO = 0.03
+def _recover_native_table_html(
+ source: _PageSource,
+ table_bbox: BBox,
+ angle: int,
+ chars: tuple[Char, ...] | None = None,
+ drawing_lines: tuple[NativeTableRule, ...] | None = None,
+ rectangles: tuple[NativeTableRectangle, ...] | 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)
+ ),
+ )
+ )
+ return result.html if result is not None else ""
+
+
def _detect_table_candidates(
source: _PageSource,
excluded_bboxes: list[BBox] | None = None,
@@ -2014,6 +2054,9 @@ def _materialize_table_blocks(
annotation_blocks: list[dict[str, Any]] = []
accepted_candidate_bboxes: list[BBox] = []
claimed: set[int] = set()
+ native_chars = tuple(source.chars)
+ native_rules = coerce_native_table_rules(source.drawing_lines)
+ native_rectangles = coerce_native_table_rectangles(source.path_infos)
for candidate in sorted(candidates, key=lambda item: item.score, reverse=True):
# 候选去重仍使用包含注释的完整框,不能因输出表体收缩而放行重复表格。
if any(
@@ -2033,13 +2076,34 @@ def _materialize_table_blocks(
candidate,
failed_annotations,
)
+ content = ""
try:
- # 使用完整原始字符流保留 PDF 物理换行;行索引仅负责表体与注释的所有权认领。
- content = project_pdf_table_text(
- source.chars,
+ content = _recover_native_table_html(
+ source,
body_bbox,
- angle=candidate.angle,
+ candidate.angle,
+ native_chars,
+ native_rules,
+ native_rectangles,
+ )
+ except Exception as exc:
+ logger.warning(
+ "Flash native table recovery failed and fell back to projection: "
+ f"bbox={candidate.bbox}, error={exc}"
+ )
+ if content:
+ logger.debug(
+ "Flash native table recovery accepted: "
+ f"bbox={body_bbox}, angle={candidate.angle}"
)
+ try:
+ if not content:
+ # 使用完整原始字符流保留 PDF 物理换行;行索引仅负责表体与注释的所有权认领。
+ content = project_pdf_table_text(
+ source.chars,
+ body_bbox,
+ angle=candidate.angle,
+ )
except Exception as exc:
# 表体投影异常时同时撤销预构造注释,保持整组不输出、不认领。
logger.warning(f"Flash table projection failed and rolled back: bbox={candidate.bbox}, error={exc}")
diff --git a/mineru/utils/native_pdf_table/__init__.py b/mineru/utils/native_pdf_table/__init__.py
new file mode 100644
index 00000000..13b6abaa
--- /dev/null
+++ b/mineru/utils/native_pdf_table/__init__.py
@@ -0,0 +1,26 @@
+# Copyright (c) Opendatalab. All rights reserved.
+"""面向已有 table bbox 的 Native PDF 表格结构恢复公共内部入口。"""
+
+from .contracts import (
+ NativeTableCell,
+ NativeTableInput,
+ NativeTableRectangle,
+ NativeTableResult,
+ NativeTableRule,
+)
+from .engine import (
+ coerce_native_table_rectangles,
+ coerce_native_table_rules,
+ recover_native_pdf_table,
+)
+
+__all__ = [
+ "NativeTableCell",
+ "NativeTableInput",
+ "NativeTableRectangle",
+ "NativeTableResult",
+ "NativeTableRule",
+ "coerce_native_table_rectangles",
+ "coerce_native_table_rules",
+ "recover_native_pdf_table",
+]
diff --git a/mineru/utils/native_pdf_table/candidate.py b/mineru/utils/native_pdf_table/candidate.py
new file mode 100644
index 00000000..970de4c6
--- /dev/null
+++ b/mineru/utils/native_pdf_table/candidate.py
@@ -0,0 +1,230 @@
+# Copyright (c) Opendatalab. All rights reserved.
+"""Native PDF 表格候选的网格校验、字符落格和 HTML 序列化。"""
+
+from __future__ import annotations
+
+import html
+from dataclasses import dataclass
+
+from mineru.types import BBox
+
+from .contracts import (
+ NativeTableCandidate,
+ NativeTableCandidateSource,
+ NativeTableCell,
+ NativeTableGlyph,
+ NativeTableText,
+)
+from .geometry import bbox_center
+from .text import build_cell_text, glyph_overlap_ratio
+
+MIN_TEXT_CAPTURE = 0.98
+
+
+@dataclass(frozen=True, slots=True)
+class GridCellSpec:
+ """保存尚未回填文本的逻辑网格单元格。"""
+
+ row: int
+ col: int
+ rowspan: int
+ colspan: int
+ bbox: BBox
+
+
+def _validate_grid_specs(
+ rows: int,
+ cols: int,
+ specs: tuple[GridCellSpec, ...],
+ *,
+ allow_single_row: bool = False,
+ allow_single_column: bool = False,
+) -> bool:
+ """校验逻辑单元格完整覆盖矩形网格且没有重叠。"""
+
+ minimum_rows = 1 if allow_single_row else 2
+ minimum_cols = 1 if allow_single_column else 2
+ if rows < minimum_rows or cols < minimum_cols or (rows == 1 and cols == 1) or not specs:
+ return False
+ occupied = [[False for _ in range(cols)] for _ in range(rows)]
+ for spec in specs:
+ if (
+ spec.row < 0
+ or spec.col < 0
+ or spec.rowspan < 1
+ or spec.colspan < 1
+ or spec.row + spec.rowspan > rows
+ or spec.col + spec.colspan > cols
+ or spec.bbox[2] <= spec.bbox[0]
+ or spec.bbox[3] <= spec.bbox[1]
+ ):
+ return False
+ for row_index in range(spec.row, spec.row + spec.rowspan):
+ for col_index in range(spec.col, spec.col + spec.colspan):
+ if occupied[row_index][col_index]:
+ return False
+ occupied[row_index][col_index] = True
+ return all(all(row) for row in occupied)
+
+
+def _choose_cell_for_glyph(
+ glyph: NativeTableGlyph,
+ specs: tuple[GridCellSpec, ...],
+) -> tuple[int | None, bool]:
+ """按字符面积交叠选择唯一单元格,并标记近似平局的边界歧义。"""
+
+ overlaps = [(glyph_overlap_ratio(glyph, spec.bbox), index) for index, spec in enumerate(specs)]
+ overlaps.sort(reverse=True)
+ best_ratio, best_index = overlaps[0]
+ if best_ratio <= 0:
+ center_x, center_y = bbox_center(glyph.bbox)
+ containing = [
+ index
+ for index, spec in enumerate(specs)
+ if spec.bbox[0] <= center_x <= spec.bbox[2] and spec.bbox[1] <= center_y <= spec.bbox[3]
+ ]
+ return (containing[0], False) if len(containing) == 1 else (None, False)
+ ambiguous = len(overlaps) > 1 and overlaps[1][0] >= 0.45 and abs(best_ratio - overlaps[1][0]) <= 0.02
+ return best_index, ambiguous
+
+
+def _order_consistency(
+ text: NativeTableText,
+ assignments: dict[int, int],
+ specs: tuple[GridCellSpec, ...],
+) -> float:
+ """衡量每条视觉行中的字符单元格序号是否保持从左到右单调。"""
+
+ comparable = 0
+ ordered_pairs = 0
+ glyph_by_id = {glyph.glyph_id: glyph for glyph in text.glyphs}
+ for row in text.rows:
+ glyphs = sorted(
+ (glyph_by_id[glyph_id] for glyph_id in row.glyph_ids if glyph_id in assignments),
+ key=lambda glyph: (glyph.bbox[0], glyph.glyph_id),
+ )
+ previous_position: tuple[int, int] | None = None
+ for glyph in glyphs:
+ spec = specs[assignments[glyph.glyph_id]]
+ position = spec.row, spec.col
+ if previous_position is not None:
+ comparable += 1
+ if position >= previous_position:
+ ordered_pairs += 1
+ previous_position = position
+ return ordered_pairs / comparable if comparable else 1.0
+
+
+def build_candidate(
+ *,
+ source: NativeTableCandidateSource,
+ rows: int,
+ cols: int,
+ specs: tuple[GridCellSpec, ...],
+ text: NativeTableText,
+ structure_support: float,
+ row_stability: float,
+ column_stability: float,
+ issues: tuple[str, ...] = (),
+ allow_single_row: bool = False,
+ allow_single_column: bool = False,
+) -> NativeTableCandidate | None:
+ """校验网格、唯一分配字符并计算统一质量分。"""
+
+ if not _validate_grid_specs(
+ rows,
+ cols,
+ specs,
+ allow_single_row=allow_single_row,
+ allow_single_column=allow_single_column,
+ ):
+ return None
+ assignments: dict[int, int] = {}
+ cell_glyphs: list[list[NativeTableGlyph]] = [[] for _ in specs]
+ ambiguous_count = 0
+ for glyph in text.glyphs:
+ cell_index, ambiguous = _choose_cell_for_glyph(glyph, specs)
+ if cell_index is None:
+ continue
+ assignments[glyph.glyph_id] = cell_index
+ cell_glyphs[cell_index].append(glyph)
+ ambiguous_count += int(ambiguous)
+
+ glyph_count = len(text.glyphs)
+ text_capture = len(assignments) / glyph_count if glyph_count else 0.0
+ ambiguous_ratio = ambiguous_count / glyph_count if glyph_count else 0.0
+ if text_capture < MIN_TEXT_CAPTURE or ambiguous_ratio > 0.02:
+ return None
+ cells = tuple(
+ NativeTableCell(
+ row=spec.row,
+ col=spec.col,
+ rowspan=spec.rowspan,
+ colspan=spec.colspan,
+ bbox=spec.bbox,
+ content=build_cell_text(
+ cell_glyphs[index],
+ text.median_glyph_height,
+ ),
+ source_char_indices=tuple(
+ glyph.source_index
+ for glyph in sorted(
+ cell_glyphs[index],
+ key=lambda item: (item.visual_row, item.bbox[0], item.glyph_id),
+ )
+ ),
+ )
+ for index, spec in enumerate(specs)
+ )
+ order_consistency = _order_consistency(text, assignments, specs)
+ normalized_structure = max(0.0, min(1.0, structure_support))
+ normalized_row = max(0.0, min(1.0, row_stability))
+ normalized_column = max(0.0, min(1.0, column_stability))
+ score = min(
+ text_capture,
+ normalized_structure,
+ normalized_row,
+ normalized_column,
+ order_consistency,
+ )
+ return NativeTableCandidate(
+ source=source,
+ rows=rows,
+ cols=cols,
+ cells=cells,
+ score=score,
+ text_capture=text_capture,
+ structure_support=normalized_structure,
+ row_stability=normalized_row,
+ column_stability=normalized_column,
+ order_consistency=order_consistency,
+ issues=issues,
+ )
+
+
+def serialize_candidate_html(candidate: NativeTableCandidate) -> str:
+ """把合法候选序列化为稳定、转义且不猜测表头语义的 HTML。"""
+
+ cells_by_row: dict[int, list[NativeTableCell]] = {}
+ for cell in candidate.cells:
+ cells_by_row.setdefault(cell.row, []).append(cell)
+ rendered_rows: list[str] = []
+ for row_index in range(candidate.rows):
+ rendered_cells: list[str] = []
+ for cell in sorted(cells_by_row.get(row_index, []), key=lambda item: item.col):
+ attributes = []
+ if cell.rowspan > 1:
+ 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>")
+ rendered_rows.append(f"<tr>{''.join(rendered_cells)}</tr>")
+ return f"<table><tbody>{''.join(rendered_rows)}</tbody></table>"
+
+
+__all__ = [
+ "GridCellSpec",
+ "build_candidate",
+ "serialize_candidate_html",
+]
diff --git a/mineru/utils/native_pdf_table/contracts.py b/mineru/utils/native_pdf_table/contracts.py
new file mode 100644
index 00000000..acae840d
--- /dev/null
+++ b/mineru/utils/native_pdf_table/contracts.py
@@ -0,0 +1,152 @@
+# Copyright (c) Opendatalab. All rights reserved.
+"""Native PDF 表格结构恢复使用的中立内部数据契约。"""
+
+from __future__ import annotations
+
+from dataclasses import dataclass, field
+from typing import Literal
+
+from pdftext.schema import Char
+
+from mineru.types import BBox
+
+NativeTableCandidateSource = Literal[
+ "vector_grid",
+ "sparse_grid",
+ "text_grid",
+ "key_value",
+]
+
+
+@dataclass(frozen=True, slots=True)
+class NativeTableRule:
+ """保存页面坐标中的一条可见横线或竖线。"""
+
+ bbox: BBox
+ width: float
+ orientation: Literal["horizontal", "vertical"]
+
+
+@dataclass(frozen=True, slots=True)
+class NativeTableRectangle:
+ """保存页面坐标中的 PDF 矩形路径及其绘制属性。"""
+
+ bbox: BBox
+ segment_count: int
+ fill_visible: bool
+ stroke_visible: bool
+ form_depth: int = 0
+
+
+@dataclass(frozen=True, slots=True)
+class NativeTableInput:
+ """保存一次已知表格区域结构恢复所需的全部页面原语。"""
+
+ table_bbox: BBox
+ page_size: tuple[float, float]
+ angle: int
+ chars: tuple[Char, ...]
+ drawing_lines: tuple[NativeTableRule, ...] = field(default_factory=tuple)
+ rectangles: tuple[NativeTableRectangle, ...] = field(default_factory=tuple)
+
+
+@dataclass(frozen=True, slots=True)
+class NativeTableGlyph:
+ """保存正向表格局部坐标中的单个可见 PDF 字符。"""
+
+ glyph_id: int
+ source_index: int
+ text: str
+ bbox: BBox
+ visual_row: int
+ explicit_space_before: bool = False
+ explicit_break_before: bool = False
+
+
+@dataclass(frozen=True, slots=True)
+class NativeTableToken:
+ """保存同一视觉行内由连续字符组成的表格文本项。"""
+
+ text: str
+ bbox: BBox
+ glyph_ids: tuple[int, ...]
+ source_char_indices: tuple[int, ...]
+
+
+@dataclass(frozen=True, slots=True)
+class NativeTableTextRow:
+ """保存表格局部坐标中的一条视觉文本行。"""
+
+ row_index: int
+ bbox: BBox
+ tokens: tuple[NativeTableToken, ...]
+ glyph_ids: tuple[int, ...]
+
+
+@dataclass(frozen=True, slots=True)
+class NativeTableText:
+ """保存统一字符预处理后的字形、文本行与尺度统计。"""
+
+ glyphs: tuple[NativeTableGlyph, ...]
+ rows: tuple[NativeTableTextRow, ...]
+ median_glyph_width: float
+ median_glyph_height: float
+
+
+@dataclass(frozen=True, slots=True)
+class NativeTableCell:
+ """保存一个逻辑单元格的网格位置、内容和字符来源。"""
+
+ row: int
+ col: int
+ rowspan: int
+ colspan: int
+ bbox: BBox
+ content: str
+ source_char_indices: tuple[int, ...] = field(default_factory=tuple)
+
+
+@dataclass(frozen=True, slots=True)
+class NativeTableCandidate:
+ """保存单路算法生成且已完成文本落格的表格候选。"""
+
+ source: NativeTableCandidateSource
+ rows: int
+ cols: int
+ cells: tuple[NativeTableCell, ...]
+ score: float
+ text_capture: float
+ structure_support: float
+ row_stability: float
+ column_stability: float
+ order_consistency: float
+ issues: tuple[str, ...] = field(default_factory=tuple)
+
+ @property
+ def topology(self) -> tuple[int, int, tuple[tuple[int, int, int, int], ...]]:
+ """返回不含文本的稳定拓扑签名,供候选冲突仲裁。"""
+
+ spans = tuple(sorted((cell.row, cell.col, cell.rowspan, cell.colspan) for cell in self.cells))
+ return self.rows, self.cols, spans
+
+
+@dataclass(frozen=True, slots=True)
+class NativeTableResult:
+ """保存最终采用的原生表格 HTML 及其可诊断内部结构。"""
+
+ html: str
+ rows: int
+ cols: int
+ cells: tuple[NativeTableCell, ...]
+ source: NativeTableCandidateSource
+ confidence: float
+ diagnostics: tuple[str, ...] = field(default_factory=tuple)
+
+
+__all__ = [
+ "NativeTableCell",
+ "NativeTableInput",
+ "NativeTableRectangle",
+ "NativeTableResult",
+ "NativeTableRule",
+]
diff --git a/mineru/utils/native_pdf_table/engine.py b/mineru/utils/native_pdf_table/engine.py
new file mode 100644
index 00000000..a49883b0
--- /dev/null
+++ b/mineru/utils/native_pdf_table/engine.py
@@ -0,0 +1,410 @@
+# Copyright (c) Opendatalab. All rights reserved.
+"""编排 Native PDF 表格多候选生成、欠分割诊断和高置信仲裁。"""
+
+from __future__ import annotations
+
+import math
+from collections.abc import Iterable
+from dataclasses import dataclass
+from typing import Any
+
+from .candidate import serialize_candidate_html
+from .contracts import (
+ NativeTableCandidate,
+ NativeTableInput,
+ NativeTableRectangle,
+ NativeTableResult,
+ NativeTableRule,
+ NativeTableText,
+)
+from .geometry import bbox_intersection, normalize_bbox
+from .text import build_native_table_text
+from .text_grid import build_text_candidates
+from .vector import (
+ MAX_PRIMITIVES_PER_TABLE,
+ build_vector_candidates,
+ diagnose_vector_candidate_builds,
+)
+
+MIN_TOPOLOGY_SCORE_GAP = 0.05
+_SOURCE_PRIORITY = {
+ "vector_grid": 4,
+ "sparse_grid": 3,
+ "key_value": 2,
+ "text_grid": 1,
+}
+_VERIFIED_SCORE_BY_SOURCE = {
+ "vector_grid": 0.95,
+ "sparse_grid": 0.95,
+ "key_value": 0.95,
+ "text_grid": 0.95,
+}
+
+
+@dataclass(frozen=True, slots=True)
+class _CandidateEvaluation:
+ """保存一次生产决策及调试工具需要的中间候选。"""
+
+ primitive_count: int
+ text: NativeTableText | None
+ generated_candidates: tuple[NativeTableCandidate, ...]
+ candidates: tuple[NativeTableCandidate, ...]
+ selected: NativeTableCandidate | None
+ first_rejection_gate: str | None
+
+
+def _is_verified_line_candidate(candidate: NativeTableCandidate) -> bool:
+ """判断候选是否由无歧义 drawing 网格独立验证。"""
+
+ return (
+ candidate.source == "vector_grid"
+ and candidate.score >= 0.95
+ and "evidence=line_grid" in candidate.issues
+ and "ambiguous_separator_ratio=0.0000" in candidate.issues
+ )
+
+
+def _passes_verified_threshold(candidate: NativeTableCandidate) -> bool:
+ """按候选来源应用独立校准的 verified 可靠度门槛。"""
+
+ return candidate.score >= _VERIFIED_SCORE_BY_SOURCE[candidate.source]
+
+
+def _read_value(item: object, name: str, default: Any = None) -> Any:
+ """同时读取普通对象属性和字典字段,供页面原语适配使用。"""
+
+ if isinstance(item, dict):
+ return item.get(name, default)
+ return getattr(item, name, default)
+
+
+def coerce_native_table_rules(
+ drawing_lines: Iterable[object],
+) -> tuple[NativeTableRule, ...]:
+ """把 PDFDocument 或 Flash drawing 结果转换成共享横竖线契约。"""
+
+ rules: list[NativeTableRule] = []
+ for drawing_line in drawing_lines:
+ bbox = normalize_bbox(_read_value(drawing_line, "bbox"))
+ orientation = str(_read_value(drawing_line, "orientation", ""))
+ if bbox is None or orientation not in {"horizontal", "vertical"}:
+ continue
+ try:
+ width = max(0.0, float(_read_value(drawing_line, "width", 0.0) or 0.0))
+ except (TypeError, ValueError):
+ width = 0.0
+ rules.append(
+ NativeTableRule(
+ bbox=bbox,
+ width=width,
+ orientation=orientation, # type: ignore[arg-type]
+ )
+ )
+ return tuple(rules)
+
+
+def coerce_native_table_rectangles(
+ path_infos: Iterable[object],
+) -> tuple[NativeTableRectangle, ...]:
+ """把 PDF Path 摘要转换成共享矩形路径契约。"""
+
+ rectangles: list[NativeTableRectangle] = []
+ for path_info in path_infos:
+ bbox = normalize_bbox(_read_value(path_info, "bbox"))
+ if bbox is None:
+ continue
+ try:
+ segment_count = int(_read_value(path_info, "segment_count", 0) or 0)
+ form_depth = int(_read_value(path_info, "form_depth", 0) or 0)
+ except (TypeError, ValueError):
+ continue
+ rectangles.append(
+ NativeTableRectangle(
+ bbox=bbox,
+ segment_count=segment_count,
+ fill_visible=bool(_read_value(path_info, "fill_visible", False)),
+ stroke_visible=bool(_read_value(path_info, "stroke_visible", False)),
+ form_depth=form_depth,
+ )
+ )
+ return tuple(rectangles)
+
+
+def _remove_undercounted_vector_candidates(
+ candidates: list[NativeTableCandidate],
+) -> list[NativeTableCandidate]:
+ """当稳定文本候选显著多出行列时,剔除欠分割矢量候选。"""
+
+ text_candidates = [
+ candidate
+ for candidate in candidates
+ if candidate.source != "vector_grid" and candidate.row_stability >= 0.80 and candidate.column_stability >= 0.80
+ ]
+ if not text_candidates:
+ return candidates
+ output: list[NativeTableCandidate] = []
+ for candidate in candidates:
+ if candidate.source != "vector_grid":
+ output.append(candidate)
+ continue
+ if _is_verified_line_candidate(candidate):
+ output.append(candidate)
+ continue
+ undercounted = any(
+ text_candidate.rows >= math.ceil(1.5 * candidate.rows) or text_candidate.cols >= math.ceil(1.3 * candidate.cols)
+ for text_candidate in text_candidates
+ )
+ if not undercounted:
+ output.append(candidate)
+ return output
+
+
+def _has_alias_affected_physical_blank_row(
+ vector_attempts: tuple[dict[str, Any], ...],
+) -> bool:
+ """判断强线框空白行是否因自身 alias 风险而禁止文本候选绕过。"""
+
+ for attempt in vector_attempts:
+ if attempt.get("evidence") != "line_grid":
+ continue
+ hypotheses = [attempt, *attempt.get("track_hypotheses", [])]
+ for hypothesis in hypotheses:
+ if hypothesis.get("first_rejection_gate") != "empty_row":
+ continue
+ empty_rows = set(hypothesis.get("empty_rows", []))
+ affected_rows = set(hypothesis.get("alias_affected_rows", []))
+ if empty_rows.intersection(affected_rows):
+ return True
+ return False
+
+
+def _table_primitive_count(table_input: NativeTableInput) -> int:
+ """统计实际与目标表格相交的 drawing 和矩形数量。"""
+
+ table_bbox = normalize_bbox(table_input.table_bbox)
+ if table_bbox is None:
+ return 0
+ count = 0
+ for primitive in (*table_input.drawing_lines, *table_input.rectangles):
+ primitive_bbox = normalize_bbox(primitive.bbox)
+ if primitive_bbox is not None and bbox_intersection(primitive_bbox, table_bbox) is not None:
+ count += 1
+ return count
+
+
+def _select_candidate(
+ candidates: list[NativeTableCandidate],
+) -> NativeTableCandidate | None:
+ """选择达到生产门槛且未与近分异构候选冲突的最佳结果。"""
+
+ accepted = [candidate for candidate in candidates if _passes_verified_threshold(candidate)]
+ if not accepted:
+ return None
+ verified_line_candidates = [candidate for candidate in accepted if _is_verified_line_candidate(candidate)]
+ if len(verified_line_candidates) == 1:
+ return verified_line_candidates[0]
+ accepted.sort(
+ key=lambda candidate: (
+ candidate.score,
+ _SOURCE_PRIORITY[candidate.source],
+ ),
+ reverse=True,
+ )
+ best = accepted[0]
+ for competitor in accepted[1:]:
+ if competitor.topology == best.topology:
+ continue
+ if best.score - competitor.score < MIN_TOPOLOGY_SCORE_GAP:
+ return None
+ return best
+
+
+def _evaluate_native_pdf_table(
+ table_input: NativeTableInput,
+) -> _CandidateEvaluation:
+ """执行共享生产判定,并保留候选生成到仲裁的完整阶段结果。"""
+
+ table_bbox = normalize_bbox(table_input.table_bbox)
+ page_width, page_height = table_input.page_size
+ primitive_count = _table_primitive_count(table_input)
+ if (
+ table_bbox is None
+ or page_width <= 0
+ or page_height <= 0
+ or table_bbox[0] < 0
+ or table_bbox[1] < 0
+ or table_bbox[2] > page_width
+ or table_bbox[3] > page_height
+ ):
+ return _CandidateEvaluation(
+ primitive_count,
+ None,
+ (),
+ (),
+ None,
+ "input_geometry",
+ )
+ if primitive_count > MAX_PRIMITIVES_PER_TABLE:
+ return _CandidateEvaluation(
+ primitive_count,
+ None,
+ (),
+ (),
+ None,
+ "primitive_limit",
+ )
+ text = build_native_table_text(table_input)
+ if text is None:
+ return _CandidateEvaluation(
+ primitive_count,
+ None,
+ (),
+ (),
+ None,
+ "native_text",
+ )
+ vector_candidates = build_vector_candidates(table_input, text)
+ text_candidates = build_text_candidates(table_input, text) if len(text.rows) >= 2 else []
+ if not vector_candidates and text_candidates:
+ vector_attempts = diagnose_vector_candidate_builds(
+ table_input,
+ text,
+ )
+ if _has_alias_affected_physical_blank_row(vector_attempts):
+ text_candidates = []
+ generated_candidates = [*vector_candidates, *text_candidates]
+ candidates = _remove_undercounted_vector_candidates(generated_candidates)
+ selected = _select_candidate(candidates)
+ if selected is not None:
+ first_rejection_gate = None
+ elif not generated_candidates:
+ first_rejection_gate = "candidate_generation"
+ elif not candidates:
+ first_rejection_gate = "undercount_guard"
+ elif not any(_passes_verified_threshold(candidate) for candidate in candidates):
+ first_rejection_gate = "verified_threshold"
+ else:
+ first_rejection_gate = "topology_conflict"
+ return _CandidateEvaluation(
+ primitive_count,
+ text,
+ tuple(generated_candidates),
+ tuple(candidates),
+ selected,
+ first_rejection_gate,
+ )
+
+
+def diagnose_native_pdf_table(table_input: NativeTableInput) -> dict[str, Any]:
+ """返回仅供测试评测使用、不会进入用户结果的候选诊断。"""
+
+ evaluation = _evaluate_native_pdf_table(table_input)
+ vector_attempts = (
+ diagnose_vector_candidate_builds(
+ table_input,
+ evaluation.text,
+ )
+ if evaluation.text is not None
+ else ()
+ )
+ first_rejection_gate = evaluation.first_rejection_gate
+ if first_rejection_gate == "candidate_generation":
+ line_attempt = next(
+ (attempt for attempt in vector_attempts if attempt.get("evidence") == "line_grid"),
+ None,
+ )
+ if line_attempt is not None and line_attempt.get("first_rejection_gate"):
+ first_rejection_gate = "vector_" + str(line_attempt["first_rejection_gate"])
+
+ def candidate_record(
+ candidate: NativeTableCandidate,
+ ) -> dict[str, Any]:
+ """把内部候选转换成稳定且不包含单元格全文的诊断记录。"""
+
+ return {
+ "source": candidate.source,
+ "rows": candidate.rows,
+ "cols": candidate.cols,
+ "tracks": {
+ "x": candidate.cols + 1,
+ "y": candidate.rows + 1,
+ },
+ "score": candidate.score,
+ "verified": _passes_verified_threshold(candidate),
+ "score_components": {
+ "text_capture": candidate.text_capture,
+ "structure_support": candidate.structure_support,
+ "row_stability": candidate.row_stability,
+ "column_stability": candidate.column_stability,
+ "order_consistency": candidate.order_consistency,
+ },
+ "span_signature": [
+ [cell.row, cell.col, cell.rowspan, cell.colspan]
+ for cell in candidate.cells
+ if cell.rowspan > 1 or cell.colspan > 1
+ ],
+ "issues": list(candidate.issues),
+ }
+
+ retained_ids = {id(candidate) for candidate in evaluation.candidates}
+ removed_candidates = [
+ candidate_record(candidate) for candidate in evaluation.generated_candidates if id(candidate) not in retained_ids
+ ]
+ counterfactual_best = max(
+ evaluation.generated_candidates,
+ key=lambda candidate: (
+ candidate.score,
+ _SOURCE_PRIORITY[candidate.source],
+ ),
+ default=None,
+ )
+ return {
+ "primitive_count": evaluation.primitive_count,
+ "glyph_count": len(evaluation.text.glyphs) if evaluation.text else 0,
+ "visual_text_rows": len(evaluation.text.rows) if evaluation.text else 0,
+ "first_rejection_gate": first_rejection_gate,
+ "vector_attempts": list(vector_attempts),
+ "generated_candidates": [candidate_record(candidate) for candidate in evaluation.generated_candidates],
+ "removed_by_undercount": removed_candidates,
+ "counterfactual_best": (candidate_record(counterfactual_best) if counterfactual_best is not None else None),
+ "adopted": (candidate_record(evaluation.selected) if evaluation.selected is not None else None),
+ }
+
+
+def recover_native_pdf_table(
+ table_input: NativeTableInput,
+) -> NativeTableResult | None:
+ """对一个已知表格区域运行全部候选并返回高置信 HTML 结果。"""
+
+ evaluation = _evaluate_native_pdf_table(table_input)
+ selected = evaluation.selected
+ if selected is None:
+ return None
+ diagnostics = tuple(
+ [
+ f"candidate={selected.source}",
+ f"score={selected.score:.4f}",
+ f"text_capture={selected.text_capture:.4f}",
+ f"structure_support={selected.structure_support:.4f}",
+ f"row_stability={selected.row_stability:.4f}",
+ f"column_stability={selected.column_stability:.4f}",
+ f"order_consistency={selected.order_consistency:.4f}",
+ ]
+ + list(selected.issues)
+ )
+ return NativeTableResult(
+ html=serialize_candidate_html(selected),
+ rows=selected.rows,
+ cols=selected.cols,
+ cells=selected.cells,
+ source=selected.source,
+ confidence=selected.score,
+ diagnostics=diagnostics,
+ )
+
+
+__all__ = [
+ "coerce_native_table_rectangles",
+ "coerce_native_table_rules",
+ "recover_native_pdf_table",
+]
diff --git a/mineru/utils/native_pdf_table/geometry.py b/mineru/utils/native_pdf_table/geometry.py
new file mode 100644
index 00000000..b3996d45
--- /dev/null
+++ b/mineru/utils/native_pdf_table/geometry.py
@@ -0,0 +1,196 @@
+# Copyright (c) Opendatalab. All rights reserved.
+"""Native PDF 表格结构恢复使用的局部坐标与聚类原语。"""
+
+from __future__ import annotations
+
+from collections.abc import Iterable
+
+from mineru.types import BBox
+
+
+def normalize_bbox(value: object) -> BBox | None:
+ """把任意四元组规范为有效浮点 bbox,异常或退化框返回空。"""
+
+ try:
+ x0, y0, x1, y1 = [float(item) for item in value] # type: ignore[arg-type]
+ except (TypeError, ValueError):
+ return None
+ left, right = sorted((x0, x1))
+ top, bottom = sorted((y0, y1))
+ if right <= left or bottom <= top:
+ return None
+ return left, top, right, bottom
+
+
+def normalize_angle(value: object) -> int:
+ """把输入角度限制为表格流程支持的四个标准方向。"""
+
+ try:
+ angle = int(float(value or 0)) % 360
+ except (TypeError, ValueError):
+ return 0
+ return angle if angle in {0, 90, 180, 270} else 0
+
+
+def bbox_area(bbox: BBox) -> float:
+ """返回 bbox 的非负面积。"""
+
+ return max(0.0, float(bbox[2]) - float(bbox[0])) * max(
+ 0.0,
+ float(bbox[3]) - float(bbox[1]),
+ )
+
+
+def bbox_union(bboxes: Iterable[BBox]) -> BBox:
+ """返回一组有效 bbox 的最小外接框。"""
+
+ items = list(bboxes)
+ if not items:
+ raise ValueError("bbox union requires at least one bbox")
+ return (
+ min(item[0] for item in items),
+ min(item[1] for item in items),
+ max(item[2] for item in items),
+ max(item[3] for item in items),
+ )
+
+
+def bbox_intersection(first: BBox, second: BBox) -> BBox | None:
+ """返回两个 bbox 的有效交集,无交集时返回空。"""
+
+ intersection = (
+ max(first[0], second[0]),
+ max(first[1], second[1]),
+ min(first[2], second[2]),
+ min(first[3], second[3]),
+ )
+ return intersection if intersection[2] > intersection[0] and intersection[3] > intersection[1] else None
+
+
+def bbox_overlap_ratio(inner: BBox, outer: BBox) -> float:
+ """返回 inner 面积被 outer 覆盖的比例。"""
+
+ area = bbox_area(inner)
+ intersection = bbox_intersection(inner, outer)
+ if area <= 0 or intersection is None:
+ return 0.0
+ return min(1.0, bbox_area(intersection) / area)
+
+
+def bbox_center(bbox: BBox) -> tuple[float, float]:
+ """返回 bbox 的中心坐标。"""
+
+ return (bbox[0] + bbox[2]) / 2.0, (bbox[1] + bbox[3]) / 2.0
+
+
+def rotate_local_bbox(
+ bbox: BBox,
+ width: float,
+ height: float,
+ angle: int,
+) -> BBox:
+ """把表格裁剪框内 bbox 转换到正向表格局部坐标。"""
+
+ x0, y0, x1, y1 = bbox
+ if angle == 270:
+ return height - y1, x0, height - y0, x1
+ if angle == 90:
+ return y0, width - x1, y1, width - x0
+ if angle == 180:
+ return width - x1, height - y1, width - x0, height - y0
+ return bbox
+
+
+def page_bbox_to_table_local(
+ bbox: BBox,
+ table_bbox: BBox,
+ angle: int,
+) -> BBox | None:
+ """裁剪页面 bbox 并转换到正向表格局部坐标。"""
+
+ clipped = bbox_intersection(bbox, table_bbox)
+ if clipped is None:
+ return None
+ width = table_bbox[2] - table_bbox[0]
+ height = table_bbox[3] - table_bbox[1]
+ relative = (
+ clipped[0] - table_bbox[0],
+ clipped[1] - table_bbox[1],
+ clipped[2] - table_bbox[0],
+ clipped[3] - table_bbox[1],
+ )
+ return rotate_local_bbox(relative, width, height, angle)
+
+
+def table_local_size(table_bbox: BBox, angle: int) -> tuple[float, float]:
+ """返回旋转到正向后的表格局部宽高。"""
+
+ width = table_bbox[2] - table_bbox[0]
+ height = table_bbox[3] - table_bbox[1]
+ return (height, width) if angle in {90, 270} else (width, height)
+
+
+def clamp(value: float, minimum: float, maximum: float) -> float:
+ """把浮点值限制在闭区间内。"""
+
+ return max(minimum, min(maximum, value))
+
+
+def cluster_positions(values: Iterable[float], tolerance: float) -> list[float]:
+ """按相邻距离聚类一维坐标,并返回各簇均值。"""
+
+ ordered = sorted(float(value) for value in values)
+ if not ordered:
+ return []
+ clusters: list[list[float]] = [[ordered[0]]]
+ for value in ordered[1:]:
+ current_mean = sum(clusters[-1]) / len(clusters[-1])
+ if abs(value - current_mean) <= tolerance:
+ clusters[-1].append(value)
+ else:
+ clusters.append([value])
+ return [sum(cluster) / len(cluster) for cluster in clusters]
+
+
+def covered_interval_ratio(
+ intervals: Iterable[tuple[float, float]],
+ start: float,
+ end: float,
+) -> float:
+ """返回若干区间在目标区间上的并集覆盖比例。"""
+
+ if end <= start:
+ return 0.0
+ clipped = sorted(
+ (max(start, min(first, second)), min(end, max(first, second)))
+ for first, second in intervals
+ if min(end, max(first, second)) > max(start, min(first, second))
+ )
+ if not clipped:
+ return 0.0
+ covered = 0.0
+ current_start, current_end = clipped[0]
+ for item_start, item_end in clipped[1:]:
+ if item_start <= current_end:
+ current_end = max(current_end, item_end)
+ continue
+ covered += current_end - current_start
+ current_start, current_end = item_start, item_end
+ covered += current_end - current_start
+ return min(1.0, covered / (end - start))
+
+
+__all__ = [
+ "bbox_area",
+ "bbox_center",
+ "bbox_intersection",
+ "bbox_overlap_ratio",
+ "bbox_union",
+ "clamp",
+ "cluster_positions",
+ "covered_interval_ratio",
+ "normalize_angle",
+ "normalize_bbox",
+ "page_bbox_to_table_local",
+ "table_local_size",
+]
diff --git a/mineru/utils/native_pdf_table/text.py b/mineru/utils/native_pdf_table/text.py
new file mode 100644
index 00000000..74099679
--- /dev/null
+++ b/mineru/utils/native_pdf_table/text.py
@@ -0,0 +1,305 @@
+# Copyright (c) Opendatalab. All rights reserved.
+"""Native PDF 表格字符选择、视觉组行和单元格文本重建。"""
+
+from __future__ import annotations
+
+import statistics
+from dataclasses import dataclass
+
+from pdftext.schema import Char
+
+from mineru.types import BBox
+from mineru.utils.spatial_text import _normalize_table_text
+
+from .contracts import (
+ NativeTableGlyph,
+ NativeTableInput,
+ NativeTableText,
+ NativeTableTextRow,
+ NativeTableToken,
+)
+from .geometry import (
+ bbox_center,
+ bbox_intersection,
+ bbox_union,
+ normalize_angle,
+ normalize_bbox,
+ page_bbox_to_table_local,
+)
+
+
+@dataclass(frozen=True, slots=True)
+class _PendingGlyph:
+ """保存尚未分配视觉行的局部 PDF 字符。"""
+
+ glyph_id: int
+ source_index: int
+ text: str
+ bbox: BBox
+ explicit_space_before: bool = False
+ explicit_break_before: bool = False
+
+
+def _select_pending_glyphs(table_input: NativeTableInput) -> list[_PendingGlyph]:
+ """按字符中心选择表格内可见字符,并转换到正向局部坐标。"""
+
+ table_bbox = normalize_bbox(table_input.table_bbox)
+ if table_bbox is None:
+ return []
+ selected: list[tuple[int, int, Char]] = []
+ for fallback_index, char in enumerate(table_input.chars):
+ char_bbox = normalize_bbox(char.get("bbox"))
+ if char_bbox is None:
+ continue
+ center_x, center_y = bbox_center(char_bbox)
+ if not (table_bbox[0] <= center_x <= table_bbox[2] and table_bbox[1] <= center_y <= table_bbox[3]):
+ continue
+ try:
+ source_index = int(char.get("char_idx", fallback_index))
+ except (TypeError, ValueError):
+ source_index = fallback_index
+ selected.append((source_index, fallback_index, char))
+
+ selected.sort(key=lambda item: (item[0], item[1]))
+ output: list[_PendingGlyph] = []
+ angle = normalize_angle(table_input.angle)
+ pending_space = False
+ pending_break = False
+ for _source_sort, fallback_index, char in selected:
+ raw_text = str(char.get("char") or "")
+ if not raw_text:
+ continue
+ if raw_text in {"\r", "\n"}:
+ pending_break = True
+ pending_space = False
+ continue
+ if raw_text.isspace():
+ if not pending_break:
+ pending_space = True
+ continue
+ text = _normalize_table_text(raw_text)
+ if not text or text.isspace():
+ continue
+ absolute_bbox = normalize_bbox(char.get("bbox"))
+ if absolute_bbox is None:
+ continue
+ local_bbox = page_bbox_to_table_local(
+ absolute_bbox,
+ table_bbox,
+ angle,
+ )
+ if local_bbox is None or local_bbox[3] - local_bbox[1] < 0.5:
+ continue
+ try:
+ source_index = int(char.get("char_idx", fallback_index))
+ except (TypeError, ValueError):
+ source_index = fallback_index
+ output.append(
+ _PendingGlyph(
+ glyph_id=len(output),
+ source_index=source_index,
+ text=text,
+ bbox=local_bbox,
+ explicit_space_before=pending_space,
+ explicit_break_before=pending_break,
+ )
+ )
+ pending_space = False
+ pending_break = False
+ return output
+
+
+def _vertical_overlap_ratio(first: BBox, second: BBox) -> float:
+ """返回两个字符框相对较小高度的垂直交叠比例。"""
+
+ overlap = min(first[3], second[3]) - max(first[1], second[1])
+ minimum_height = min(first[3] - first[1], second[3] - second[1])
+ if overlap <= 0 or minimum_height <= 0:
+ return 0.0
+ return min(1.0, overlap / minimum_height)
+
+
+def _assign_visual_rows(
+ pending: list[_PendingGlyph],
+ median_height: float,
+) -> list[list[_PendingGlyph]]:
+ """按垂直交叠和中心距离把字符聚成稳定视觉行。"""
+
+ sorted_glyphs = sorted(
+ pending,
+ key=lambda glyph: (
+ (glyph.bbox[1] + glyph.bbox[3]) / 2.0,
+ glyph.bbox[0],
+ glyph.glyph_id,
+ ),
+ )
+ rows: list[list[_PendingGlyph]] = []
+ row_bboxes: list[BBox] = []
+ for glyph in sorted_glyphs:
+ glyph_center_y = (glyph.bbox[1] + glyph.bbox[3]) / 2.0
+ best_index: int | None = None
+ best_distance = float("inf")
+ for row_index, row_bbox in enumerate(row_bboxes):
+ row_center_y = (row_bbox[1] + row_bbox[3]) / 2.0
+ distance = abs(glyph_center_y - row_center_y)
+ if (
+ _vertical_overlap_ratio(glyph.bbox, row_bbox) >= 0.45 or distance <= max(0.75, median_height * 0.40)
+ ) and distance < best_distance:
+ best_index = row_index
+ best_distance = distance
+ if best_index is None:
+ rows.append([glyph])
+ row_bboxes.append(glyph.bbox)
+ else:
+ rows[best_index].append(glyph)
+ row_bboxes[best_index] = bbox_union([row_bboxes[best_index], glyph.bbox])
+
+ ordered = sorted(
+ zip(rows, row_bboxes),
+ key=lambda item: (item[1][1], item[1][0]),
+ )
+ return [sorted(row, key=lambda glyph: (glyph.bbox[0], glyph.bbox[1], glyph.glyph_id)) for row, _bbox in ordered]
+
+
+def _contains_cjk(text: str) -> bool:
+ """判断文本是否包含常见中日韩统一表意字符。"""
+
+ return any("\u3400" <= char <= "\u9fff" for char in text)
+
+
+def _join_glyph_line(
+ glyphs: list[NativeTableGlyph] | list[_PendingGlyph],
+ median_height: float,
+) -> str:
+ """按字符间距重建单行文本,避免在中文字符之间强插空格。"""
+
+ if not glyphs:
+ return ""
+ ordered = sorted(glyphs, key=lambda glyph: (glyph.bbox[0], glyph.bbox[1], glyph.glyph_id))
+ parts = [ordered[0].text]
+ previous = ordered[0]
+ for glyph in ordered[1:]:
+ gap = glyph.bbox[0] - previous.bbox[2]
+ previous_tail = previous.text[-1:] or ""
+ current_head = glyph.text[:1] or ""
+ needs_space = glyph.explicit_space_before or (
+ not glyph.explicit_break_before
+ and gap > max(0.6, median_height * 0.20)
+ and not _contains_cjk(previous_tail + current_head)
+ and previous_tail.isprintable()
+ and current_head.isprintable()
+ )
+ if needs_space and not parts[-1].endswith(" "):
+ parts.append(" ")
+ parts.append(glyph.text)
+ previous = glyph
+ return "".join(parts).strip()
+
+
+def _tokenize_row(
+ glyphs: list[NativeTableGlyph],
+ median_width: float,
+ median_height: float,
+) -> tuple[NativeTableToken, ...]:
+ """按显著水平间隙把视觉行拆成供列推断使用的文本项。"""
+
+ if not glyphs:
+ return ()
+ split_gap = max(2.0 * median_width, 0.70 * median_height, 2.0)
+ groups: list[list[NativeTableGlyph]] = [[glyphs[0]]]
+ for glyph in glyphs[1:]:
+ if glyph.bbox[0] - groups[-1][-1].bbox[2] > split_gap:
+ groups.append([glyph])
+ else:
+ groups[-1].append(glyph)
+ tokens: list[NativeTableToken] = []
+ for group in groups:
+ content = _join_glyph_line(group, median_height)
+ if not content:
+ continue
+ tokens.append(
+ NativeTableToken(
+ text=content,
+ bbox=bbox_union(item.bbox for item in group),
+ glyph_ids=tuple(item.glyph_id for item in group),
+ source_char_indices=tuple(item.source_index for item in group),
+ )
+ )
+ return tuple(tokens)
+
+
+def build_native_table_text(table_input: NativeTableInput) -> NativeTableText | None:
+ """把原生 PDF 字符转换为正向表格字形、视觉行和文本项。"""
+
+ pending = _select_pending_glyphs(table_input)
+ if not pending:
+ return None
+ widths = [glyph.bbox[2] - glyph.bbox[0] for glyph in pending if glyph.bbox[2] > glyph.bbox[0]]
+ heights = [glyph.bbox[3] - glyph.bbox[1] for glyph in pending if glyph.bbox[3] > glyph.bbox[1]]
+ median_width = max(0.1, float(statistics.median(widths)) if widths else 1.0)
+ median_height = max(0.1, float(statistics.median(heights)) if heights else 1.0)
+ pending_rows = _assign_visual_rows(pending, median_height)
+
+ glyphs: list[NativeTableGlyph] = []
+ rows: list[NativeTableTextRow] = []
+ for row_index, pending_row in enumerate(pending_rows):
+ row_glyphs = [
+ NativeTableGlyph(
+ glyph_id=item.glyph_id,
+ source_index=item.source_index,
+ text=item.text,
+ bbox=item.bbox,
+ visual_row=row_index,
+ explicit_space_before=item.explicit_space_before,
+ explicit_break_before=item.explicit_break_before,
+ )
+ for item in pending_row
+ ]
+ glyphs.extend(row_glyphs)
+ rows.append(
+ NativeTableTextRow(
+ row_index=row_index,
+ bbox=bbox_union(item.bbox for item in row_glyphs),
+ tokens=_tokenize_row(row_glyphs, median_width, median_height),
+ glyph_ids=tuple(item.glyph_id for item in row_glyphs),
+ )
+ )
+ glyphs.sort(key=lambda item: item.glyph_id)
+ return NativeTableText(
+ glyphs=tuple(glyphs),
+ rows=tuple(rows),
+ median_glyph_width=median_width,
+ median_glyph_height=median_height,
+ )
+
+
+def build_cell_text(
+ glyphs: list[NativeTableGlyph],
+ median_height: float,
+) -> str:
+ """按视觉行和局部横向顺序重建文本,并将同一单元格内的多行直接拼接。"""
+
+ if not glyphs:
+ 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)))
+
+
+def glyph_overlap_ratio(glyph: NativeTableGlyph, bbox: BBox) -> float:
+ """返回字符框面积被目标单元格覆盖的比例。"""
+
+ intersection = bbox_intersection(glyph.bbox, bbox)
+ glyph_area = (glyph.bbox[2] - glyph.bbox[0]) * (glyph.bbox[3] - glyph.bbox[1])
+ if intersection is None or glyph_area <= 0:
+ return 0.0
+ intersection_area = (intersection[2] - intersection[0]) * (intersection[3] - intersection[1])
+ return min(1.0, intersection_area / glyph_area)
+
+
+__all__ = [
+ "build_cell_text",
+ "build_native_table_text",
+ "glyph_overlap_ratio",
+]
diff --git a/mineru/utils/native_pdf_table/text_grid.py b/mineru/utils/native_pdf_table/text_grid.py
new file mode 100644
index 00000000..8a7fdac6
--- /dev/null
+++ b/mineru/utils/native_pdf_table/text_grid.py
@@ -0,0 +1,513 @@
+# Copyright (c) Opendatalab. All rights reserved.
+"""基于稀疏规则、行底纹和原生文本对齐恢复少线或无线表格。"""
+
+from __future__ import annotations
+
+import statistics
+from collections import Counter
+
+from .candidate import GridCellSpec, build_candidate
+from .contracts import (
+ NativeTableCandidate,
+ NativeTableCandidateSource,
+ NativeTableInput,
+ NativeTableText,
+ NativeTableTextRow,
+)
+from .geometry import (
+ bbox_union,
+ normalize_angle,
+ normalize_bbox,
+ page_bbox_to_table_local,
+ table_local_size,
+)
+
+MIN_COLUMN_ANCHOR_SUPPORT = 0.60
+
+
+def _infer_target_column_count(text: NativeTableText) -> int | None:
+ """从多行文本项数量中选择有重复证据的最大叶子列数。"""
+
+ counts = [len(row.tokens) for row in text.rows if len(row.tokens) >= 2]
+ if not counts:
+ return None
+ occurrences = Counter(counts)
+ for count in sorted(occurrences, reverse=True):
+ if occurrences[count] >= 2:
+ return count
+ return max(counts) if len(text.rows) <= 3 else None
+
+
+def _infer_column_tracks(
+ text: NativeTableText,
+ width: float,
+ target_cols: int,
+) -> tuple[list[float], float, float] | None:
+ """用最稠密视觉行的相邻文本间隙推断全局叶子列边界。"""
+
+ dense_rows = [row for row in text.rows if len(row.tokens) == target_cols]
+ if len(dense_rows) < 2 and len(text.rows) > 3:
+ return None
+ if not dense_rows:
+ return None
+ boundaries: list[float] = []
+ gap_supports: list[float] = []
+ minimum_gap = max(1.0, 0.15 * text.median_glyph_height)
+ for col_index in range(target_cols - 1):
+ midpoints: list[float] = []
+ valid_gap_count = 0
+ for row in dense_rows:
+ left_token = row.tokens[col_index]
+ right_token = row.tokens[col_index + 1]
+ gap = right_token.bbox[0] - left_token.bbox[2]
+ if gap >= minimum_gap:
+ valid_gap_count += 1
+ midpoints.append((left_token.bbox[2] + right_token.bbox[0]) / 2.0)
+ if valid_gap_count / len(dense_rows) < MIN_COLUMN_ANCHOR_SUPPORT:
+ return None
+ boundaries.append(float(statistics.median(midpoints)))
+ gap_supports.append(valid_gap_count / len(dense_rows))
+ tracks = [0.0, *boundaries, width]
+ if any(current <= previous for previous, current in zip(tracks, tracks[1:])):
+ return None
+
+ first_dense_row = min(row.row_index for row in dense_rows)
+ boundary_margin = max(0.5, 0.08 * text.median_glyph_height)
+ for row in text.rows:
+ if row.row_index < first_dense_row:
+ continue
+ if any(
+ token.bbox[0] + boundary_margin < boundary < token.bbox[2] - boundary_margin
+ for token in row.tokens
+ for boundary in tracks[1:-1]
+ ):
+ return None
+
+ supported_rows_by_col: list[set[int]] = [set() for _ in range(target_cols)]
+ aligned_tokens = 0
+ total_tokens = 0
+ for row in text.rows:
+ previous_col = -1
+ for token in row.tokens:
+ center_x = (token.bbox[0] + token.bbox[2]) / 2.0
+ col = next(
+ (index for index, (left, right) in enumerate(zip(tracks, tracks[1:])) if left <= center_x <= right),
+ None,
+ )
+ total_tokens += 1
+ if col is None or col < previous_col:
+ continue
+ supported_rows_by_col[col].add(row.row_index)
+ aligned_tokens += 1
+ previous_col = col
+ row_count = max(1, len(text.rows))
+ anchor_support = sum(len(row_indices) / row_count for row_indices in supported_rows_by_col) / target_cols
+ alignment_support = aligned_tokens / total_tokens if total_tokens else 0.0
+ if anchor_support < MIN_COLUMN_ANCHOR_SUPPORT:
+ return None
+ gap_support = float(statistics.mean(gap_supports)) if gap_supports else 1.0
+ return tracks, anchor_support, min(alignment_support, gap_support)
+
+
+def _infer_row_tracks(
+ rows: tuple[NativeTableTextRow, ...],
+ height: float,
+) -> list[float] | None:
+ """用相邻逻辑行中心的中点构造完整行边界。"""
+
+ if len(rows) < 2:
+ return None
+ centers = [(row.bbox[1] + row.bbox[3]) / 2.0 for row in rows]
+ boundaries = [(previous + current) / 2.0 for previous, current in zip(centers, centers[1:])]
+ tracks = [0.0, *boundaries, height]
+ if any(current <= previous for previous, current in zip(tracks, tracks[1:])):
+ return None
+ return tracks
+
+
+def _token_columns(
+ row: NativeTableTextRow,
+ x_tracks: list[float],
+) -> list[int] | None:
+ """把一行文本项按中心点单调映射到叶子列。"""
+
+ output: list[int] = []
+ for token in row.tokens:
+ center_x = (token.bbox[0] + token.bbox[2]) / 2.0
+ col = next(
+ (index for index, (left, right) in enumerate(zip(x_tracks, x_tracks[1:])) if left <= center_x <= right),
+ None,
+ )
+ if col is None or (output and col < output[-1]):
+ return None
+ output.append(col)
+ return output
+
+
+def _has_horizontal_rule_between(
+ table_input: NativeTableInput,
+ previous: NativeTableTextRow,
+ current: NativeTableTextRow,
+) -> bool:
+ """判断两条视觉文本行之间是否存在贯穿多数表宽的物理横线。"""
+
+ table_bbox = normalize_bbox(table_input.table_bbox)
+ if table_bbox is None:
+ return True
+ angle = normalize_angle(table_input.angle)
+ width, _height = table_local_size(table_bbox, angle)
+ upper = previous.bbox[3]
+ lower = current.bbox[1]
+ for rule in table_input.drawing_lines:
+ rule_bbox = normalize_bbox(rule.bbox)
+ if rule_bbox is None:
+ continue
+ local_bbox = page_bbox_to_table_local(rule_bbox, table_bbox, angle)
+ if local_bbox is None:
+ continue
+ local_width = local_bbox[2] - local_bbox[0]
+ local_height = local_bbox[3] - local_bbox[1]
+ center_y = (local_bbox[1] + local_bbox[3]) / 2.0
+ if local_width >= 0.60 * width and local_width >= 4.0 * max(local_height, 0.1) and upper <= center_y <= lower:
+ return True
+ return False
+
+
+def _group_logical_rows(
+ table_input: NativeTableInput,
+ text: NativeTableText,
+ x_tracks: list[float],
+) -> tuple[NativeTableTextRow, ...]:
+ """保守合并同格内紧邻 continuation,避免 baseline 直接等同逻辑行。"""
+
+ groups: list[list[NativeTableTextRow]] = []
+ group_occupancy: list[set[int]] = []
+ maximum_gap = max(0.75, 0.40 * text.median_glyph_height)
+ for row in text.rows:
+ columns = _token_columns(row, x_tracks)
+ occupancy = set(columns or [])
+ if groups:
+ previous = groups[-1][-1]
+ gap = row.bbox[1] - previous.bbox[3]
+ can_continue = (
+ bool(occupancy)
+ and occupancy.issubset(group_occupancy[-1])
+ and gap <= maximum_gap
+ and not _has_horizontal_rule_between(
+ table_input,
+ previous,
+ row,
+ )
+ )
+ if can_continue:
+ groups[-1].append(row)
+ continue
+ groups.append([row])
+ group_occupancy.append(occupancy)
+
+ logical_rows: list[NativeTableTextRow] = []
+ for row_index, group in enumerate(groups):
+ logical_rows.append(
+ NativeTableTextRow(
+ row_index=row_index,
+ bbox=bbox_union(row.bbox for row in group),
+ tokens=tuple(
+ sorted(
+ (token for row in group for token in row.tokens),
+ key=lambda token: (token.bbox[0], token.bbox[1]),
+ )
+ ),
+ glyph_ids=tuple(glyph_id for row in group for glyph_id in row.glyph_ids),
+ )
+ )
+ return tuple(logical_rows)
+
+
+def _single_header_span(
+ row: NativeTableTextRow,
+ x_tracks: list[float],
+) -> tuple[int, int] | None:
+ """仅在单文本项确实横跨连续叶子列时返回保守表头 colspan。"""
+
+ if len(row.tokens) != 1:
+ return None
+ token = row.tokens[0]
+ token_width = token.bbox[2] - token.bbox[0]
+ if token_width <= 0:
+ return None
+ covered_cols = []
+ for col, (left, right) in enumerate(zip(x_tracks, x_tracks[1:])):
+ overlap = max(0.0, min(token.bbox[2], right) - max(token.bbox[0], left))
+ if overlap / token_width >= 0.20:
+ covered_cols.append(col)
+ if len(covered_cols) < 2 or covered_cols != list(range(covered_cols[0], covered_cols[-1] + 1)):
+ return None
+ return covered_cols[0], covered_cols[-1]
+
+
+def _grouped_header_spans(
+ row: NativeTableTextRow,
+ next_row: NativeTableTextRow,
+ x_tracks: list[float],
+) -> list[tuple[int, int]] | None:
+ """用下一层表头叶子列为多个分组标题推断连续 colspan。"""
+
+ if len(row.tokens) < 2:
+ single_span = _single_header_span(row, x_tracks)
+ return [single_span] if single_span is not None else None
+ child_cols = _token_columns(next_row, x_tracks)
+ if child_cols is None:
+ return None
+ unique_child_cols = sorted(set(child_cols))
+ if len(unique_child_cols) < len(row.tokens):
+ return None
+ header_centers = [(token.bbox[0] + token.bbox[2]) / 2.0 for token in row.tokens]
+ header_gaps = [current - previous for previous, current in zip(header_centers, header_centers[1:]) if current > previous]
+ maximum_child_distance = 1.5 * float(statistics.median(header_gaps)) if header_gaps else float("inf")
+ groups: list[list[int]] = [[] for _ in row.tokens]
+ for col in unique_child_cols:
+ col_center = (x_tracks[col] + x_tracks[col + 1]) / 2.0
+ owner = min(
+ range(len(header_centers)),
+ key=lambda index: abs(col_center - header_centers[index]),
+ )
+ if abs(col_center - header_centers[owner]) > maximum_child_distance:
+ continue
+ groups[owner].append(col)
+ spans: list[tuple[int, int]] = []
+ for token, cols in zip(row.tokens, groups, strict=True):
+ if not cols or cols != list(range(cols[0], cols[-1] + 1)):
+ return None
+ token_center = (token.bbox[0] + token.bbox[2]) / 2.0
+ if not x_tracks[cols[0]] <= token_center <= x_tracks[cols[-1] + 1]:
+ return None
+ spans.append((cols[0], cols[-1]))
+ return spans
+
+
+def _build_text_grid_specs(
+ rows: tuple[NativeTableTextRow, ...],
+ x_tracks: list[float],
+ y_tracks: list[float],
+ first_dense_row: int,
+) -> tuple[tuple[GridCellSpec, ...], float] | None:
+ """为每个逻辑行构造单元格,并允许前导分组表头产生 colspan。"""
+
+ cols = len(x_tracks) - 1
+ specs: list[GridCellSpec] = []
+ stable_rows = 0
+ for row_index, row in enumerate(rows):
+ occupied: set[int] = set()
+ header_spans = (
+ _grouped_header_spans(
+ row,
+ rows[row_index + 1],
+ x_tracks,
+ )
+ if row_index < first_dense_row and row_index + 1 < len(rows)
+ else None
+ )
+ if header_spans is not None:
+ for start_col, end_col in header_spans:
+ specs.append(
+ GridCellSpec(
+ row=row_index,
+ col=start_col,
+ rowspan=1,
+ colspan=end_col - start_col + 1,
+ bbox=(
+ x_tracks[start_col],
+ y_tracks[row_index],
+ x_tracks[end_col + 1],
+ y_tracks[row_index + 1],
+ ),
+ )
+ )
+ occupied.update(range(start_col, end_col + 1))
+ stable_rows += 1
+ else:
+ token_cols = _token_columns(row, x_tracks)
+ if token_cols is None:
+ return None
+ unique_cols = set(token_cols)
+ occupied.update(unique_cols)
+ if len(unique_cols) >= 2:
+ stable_rows += 1
+ for col in range(cols):
+ if col in occupied:
+ if header_spans is not None:
+ continue
+ specs.append(
+ GridCellSpec(
+ row=row_index,
+ col=col,
+ rowspan=1,
+ colspan=1,
+ bbox=(
+ x_tracks[col],
+ y_tracks[row_index],
+ x_tracks[col + 1],
+ y_tracks[row_index + 1],
+ ),
+ )
+ )
+ row_stability = stable_rows / len(rows) if rows else 0.0
+ return tuple(specs), row_stability
+
+
+def _physical_sparse_evidence(
+ table_input: NativeTableInput,
+ text: NativeTableText,
+) -> float:
+ """统计长横线和重复行底纹,为少线候选提供独立物理证据。"""
+
+ table_bbox = normalize_bbox(table_input.table_bbox)
+ if table_bbox is None:
+ return 0.0
+ angle = normalize_angle(table_input.angle)
+ width, height = table_local_size(table_bbox, angle)
+ long_horizontal_count = 0
+ for rule in table_input.drawing_lines:
+ bbox = normalize_bbox(rule.bbox)
+ if bbox is None:
+ continue
+ local_bbox = page_bbox_to_table_local(bbox, table_bbox, angle)
+ if local_bbox is None:
+ continue
+ local_width = local_bbox[2] - local_bbox[0]
+ local_height = local_bbox[3] - local_bbox[1]
+ if local_width >= 0.50 * width and local_width >= 4.0 * local_height:
+ long_horizontal_count += 1
+
+ stripe_count = 0
+ for rectangle in table_input.rectangles:
+ if rectangle.segment_count != 5 or not rectangle.fill_visible:
+ continue
+ bbox = normalize_bbox(rectangle.bbox)
+ if bbox is None:
+ continue
+ local_bbox = page_bbox_to_table_local(bbox, table_bbox, angle)
+ if local_bbox is None:
+ continue
+ local_width = local_bbox[2] - local_bbox[0]
+ local_height = local_bbox[3] - local_bbox[1]
+ if local_width >= 0.60 * width and 0.30 * text.median_glyph_height <= local_height <= min(
+ 3.0 * text.median_glyph_height, 0.50 * height
+ ):
+ stripe_count += 1
+ # 贯穿竖线只说明 vector 候选应被优先验证,不能关闭其拓扑失败后的
+ # 横线加文本兜底;异构候选最终由 verified 物理网格仲裁。
+ return min(
+ 1.0,
+ (long_horizontal_count + stripe_count) / 3.0,
+ )
+
+
+def _build_aligned_candidate(
+ *,
+ table_input: NativeTableInput,
+ text: NativeTableText,
+ source: NativeTableCandidateSource,
+ require_three_rows: bool,
+ require_three_cols: bool,
+ physical_support: float,
+) -> NativeTableCandidate | None:
+ """按统一文本轨道构造 sparse、wireless 或 key-value 候选。"""
+
+ target_cols = _infer_target_column_count(text)
+ if target_cols is None:
+ return None
+ if require_three_cols and target_cols < 3:
+ return None
+ if source == "key_value" and target_cols != 2:
+ return None
+ if require_three_rows and len(text.rows) < 3:
+ return None
+
+ table_bbox = normalize_bbox(table_input.table_bbox)
+ if table_bbox is None:
+ return None
+ width, height = table_local_size(table_bbox, normalize_angle(table_input.angle))
+ column_result = _infer_column_tracks(text, width, target_cols)
+ if column_result is None:
+ return None
+ x_tracks, anchor_support, alignment_support = column_result
+ logical_rows = _group_logical_rows(
+ table_input,
+ text,
+ x_tracks,
+ )
+ y_tracks = _infer_row_tracks(logical_rows, height)
+ if y_tracks is None:
+ return None
+ dense_row_indices = [row.row_index for row in logical_rows if len(set(_token_columns(row, x_tracks) or [])) == target_cols]
+ first_dense_row = min(dense_row_indices) if dense_row_indices else 0
+ specs_result = _build_text_grid_specs(
+ logical_rows,
+ x_tracks,
+ y_tracks,
+ first_dense_row,
+ )
+ if specs_result is None:
+ return None
+ specs, row_stability = specs_result
+ if row_stability < MIN_COLUMN_ANCHOR_SUPPORT:
+ return None
+ structure_support = max(anchor_support, physical_support) if source == "sparse_grid" else alignment_support
+ return build_candidate(
+ source=source,
+ rows=len(logical_rows),
+ cols=target_cols,
+ specs=specs,
+ text=text,
+ structure_support=structure_support,
+ row_stability=row_stability,
+ column_stability=alignment_support,
+ )
+
+
+def build_text_candidates(
+ table_input: NativeTableInput,
+ text: NativeTableText,
+) -> list[NativeTableCandidate]:
+ """同时生成少线、三列以上无线表和两列 key-value 候选。"""
+
+ candidates: list[NativeTableCandidate] = []
+ physical_support = _physical_sparse_evidence(table_input, text)
+ if physical_support > 0:
+ sparse = _build_aligned_candidate(
+ table_input=table_input,
+ text=text,
+ source="sparse_grid",
+ require_three_rows=False,
+ require_three_cols=False,
+ physical_support=physical_support,
+ )
+ if sparse is not None:
+ candidates.append(sparse)
+
+ text_grid = _build_aligned_candidate(
+ table_input=table_input,
+ text=text,
+ source="text_grid",
+ require_three_rows=True,
+ require_three_cols=True,
+ physical_support=0.0,
+ )
+ if text_grid is not None:
+ candidates.append(text_grid)
+
+ key_value = _build_aligned_candidate(
+ table_input=table_input,
+ text=text,
+ source="key_value",
+ require_three_rows=True,
+ require_three_cols=False,
+ physical_support=0.0,
+ )
+ if key_value is not None:
+ candidates.append(key_value)
+ return candidates
+
+
+__all__ = ["build_text_candidates"]
diff --git a/mineru/utils/native_pdf_table/vector.py b/mineru/utils/native_pdf_table/vector.py
new file mode 100644
index 00000000..22f4ddae
--- /dev/null
+++ b/mineru/utils/native_pdf_table/vector.py
@@ -0,0 +1,1720 @@
+# Copyright (c) Opendatalab. All rights reserved.
+"""基于 PDF 横竖线与矩形路径恢复原子网格和合并单元格。"""
+
+from __future__ import annotations
+
+import math
+import statistics
+from dataclasses import dataclass
+from typing import Any
+
+from .candidate import GridCellSpec, build_candidate
+from .contracts import (
+ NativeTableCandidate,
+ NativeTableInput,
+ NativeTableText,
+)
+from .geometry import (
+ bbox_area,
+ bbox_intersection,
+ clamp,
+ cluster_positions,
+ covered_interval_ratio,
+ normalize_angle,
+ normalize_bbox,
+ page_bbox_to_table_local,
+ rotate_local_bbox,
+ table_local_size,
+)
+
+MAX_PRIMITIVES_PER_TABLE = 5000
+MAX_TRACKS_PER_AXIS = 200
+MAX_ATOMIC_CELLS = 10000
+SEPARATOR_COVERAGE_THRESHOLD = 0.80
+MAX_TRACK_HYPOTHESES = 8
+
+
+@dataclass(frozen=True, slots=True)
+class _MergedRule:
+ """保存吸附并连接后的局部单轴线段。"""
+
+ orientation: str
+ coordinate: float
+ start: float
+ end: float
+
+
+@dataclass(frozen=True, slots=True)
+class _CanonicalTrack:
+ """保存折叠后的规范轨道及其全部原始坐标别名。"""
+
+ coordinate: float
+ aliases: tuple[float, ...]
+
+
+@dataclass(frozen=True, slots=True)
+class _PhysicalRowEvidence:
+ """保存一个原子行由 drawing 独立验证的边界可靠度。"""
+
+ row: int
+ top_coverage: float
+ bottom_coverage: float
+ left_coverage: float
+ right_coverage: float
+ height_ratio: float
+ glyph_crossing: bool
+
+ @property
+ def reliability(self) -> float:
+ """返回该行所有强物理条件中的最小可靠度。"""
+
+ if self.glyph_crossing:
+ return 0.0
+ return min(
+ self.top_coverage,
+ self.bottom_coverage,
+ self.left_coverage,
+ self.right_coverage,
+ self.height_ratio,
+ )
+
+ @property
+ def verified(self) -> bool:
+ """判断该行能否脱离文本占用独立证明结构存在。"""
+
+ return self.reliability >= SEPARATOR_COVERAGE_THRESHOLD
+
+
+@dataclass(frozen=True, slots=True)
+class _SingleRowEvidence:
+ """保存单物理行网格的全部外框和纵向隔断可靠度。"""
+
+ top_coverage: float
+ bottom_coverage: float
+ vertical_coverages: tuple[float, ...]
+ height_ratio: float
+ glyph_crossing: bool
+
+ @property
+ def reliability(self) -> float:
+ """返回单行网格所有不可替代物理证据中的最小值。"""
+
+ if self.glyph_crossing or not self.vertical_coverages:
+ return 0.0
+ return min(
+ self.top_coverage,
+ self.bottom_coverage,
+ min(self.vertical_coverages),
+ self.height_ratio,
+ )
+
+ @property
+ def verified(self) -> bool:
+ """判断单行网格是否可脱离文本对齐独立验证。"""
+
+ return self.reliability >= SEPARATOR_COVERAGE_THRESHOLD
+
+ @property
+ def confidence(self) -> float:
+ """把通过八成物理硬门的覆盖率校准到 verified 分数区间。"""
+
+ if not self.verified:
+ return 0.0
+ return min(
+ 1.0,
+ 0.95 + 0.05 * (self.reliability - SEPARATOR_COVERAGE_THRESHOLD) / (1.0 - SEPARATOR_COVERAGE_THRESHOLD),
+ )
+
+
+@dataclass(frozen=True, slots=True)
+class _SingleColumnEvidence:
+ """保存多行单列表单的横向边界和左右外框可靠度。"""
+
+ horizontal_coverages: tuple[float, ...]
+ left_coverage: float
+ right_coverage: float
+ minimum_height_ratio: float
+ glyph_crossing: bool
+
+ @property
+ def reliability(self) -> float:
+ """返回单列表单所有强物理条件中的最小可靠度。"""
+
+ if self.glyph_crossing or not self.horizontal_coverages:
+ return 0.0
+ return min(
+ min(self.horizontal_coverages),
+ self.left_coverage,
+ self.right_coverage,
+ self.minimum_height_ratio,
+ )
+
+ @property
+ def verified(self) -> bool:
+ """判断单列表单是否具备不依赖文本对齐的完整线框证据。"""
+
+ return self.reliability >= SEPARATOR_COVERAGE_THRESHOLD
+
+ @property
+ def confidence(self) -> float:
+ """把通过八成物理硬门的可靠度校准到 verified 分数区间。"""
+
+ if not self.verified:
+ return 0.0
+ return min(
+ 1.0,
+ 0.95 + 0.05 * (self.reliability - SEPARATOR_COVERAGE_THRESHOLD) / (1.0 - SEPARATOR_COVERAGE_THRESHOLD),
+ )
+
+
+class _UnionFind:
+ """维护缺失内部隔断连接的原子网格并查集。"""
+
+ def __init__(self, size: int) -> None:
+ """为固定数量原子格初始化各自独立的集合。"""
+
+ self._parents = list(range(size))
+
+ def find(self, index: int) -> int:
+ """返回原子格根节点并执行路径压缩。"""
+
+ parent = self._parents[index]
+ if parent != index:
+ self._parents[index] = self.find(parent)
+ return self._parents[index]
+
+ def union(self, first: int, second: int) -> None:
+ """合并两个原子格所属集合。"""
+
+ first_root = self.find(first)
+ second_root = self.find(second)
+ if first_root != second_root:
+ self._parents[second_root] = first_root
+
+
+def _drawing_bbox_to_table_local(
+ rule_bbox: tuple[float, float, float, float],
+ table_bbox: tuple[float, float, float, float],
+ angle: int,
+ evidence_halo: float,
+) -> tuple[float, float, float, float] | None:
+ """在不扩大字符区域的前提下,把邻近外框 drawing 转到表格局部坐标。"""
+
+ clipped = bbox_intersection(rule_bbox, table_bbox)
+ if clipped is None and evidence_halo > 0:
+ expanded_bbox = (
+ table_bbox[0] - evidence_halo,
+ table_bbox[1] - evidence_halo,
+ table_bbox[2] + evidence_halo,
+ table_bbox[3] + evidence_halo,
+ )
+ clipped = bbox_intersection(rule_bbox, expanded_bbox)
+ if clipped is None:
+ return None
+ width = table_bbox[2] - table_bbox[0]
+ height = table_bbox[3] - table_bbox[1]
+ relative = (
+ clipped[0] - table_bbox[0],
+ clipped[1] - table_bbox[1],
+ clipped[2] - table_bbox[0],
+ clipped[3] - table_bbox[1],
+ )
+ return rotate_local_bbox(relative, width, height, angle)
+
+
+def _local_rule_fragments(
+ table_input: NativeTableInput,
+ snap_tolerance: float,
+ *,
+ include_drawing: bool = True,
+ include_rectangles: bool = True,
+ evidence_halo: float = 0.0,
+) -> list[_MergedRule]:
+ """按来源裁剪 drawing/矩形,并转换为局部轴线片段。"""
+
+ table_bbox = normalize_bbox(table_input.table_bbox)
+ if table_bbox is None:
+ return []
+ angle = normalize_angle(table_input.angle)
+ fragments: list[_MergedRule] = []
+ for rule in table_input.drawing_lines if include_drawing else ():
+ rule_bbox = normalize_bbox(rule.bbox)
+ if rule_bbox is None:
+ continue
+ local_bbox = _drawing_bbox_to_table_local(
+ rule_bbox,
+ table_bbox,
+ angle,
+ evidence_halo,
+ )
+ if local_bbox is None:
+ continue
+ width = local_bbox[2] - local_bbox[0]
+ height = local_bbox[3] - local_bbox[1]
+ orientation = "horizontal" if width >= height else "vertical"
+ if orientation == "horizontal" and width >= max(1.0, 2.0 * snap_tolerance):
+ fragments.append(
+ _MergedRule(
+ orientation="horizontal",
+ coordinate=(local_bbox[1] + local_bbox[3]) / 2.0,
+ start=local_bbox[0],
+ end=local_bbox[2],
+ )
+ )
+ elif orientation == "vertical" and height >= max(1.0, 2.0 * snap_tolerance):
+ fragments.append(
+ _MergedRule(
+ orientation="vertical",
+ coordinate=(local_bbox[0] + local_bbox[2]) / 2.0,
+ start=local_bbox[1],
+ end=local_bbox[3],
+ )
+ )
+
+ local_width, local_height = table_local_size(table_bbox, angle)
+ table_area = local_width * local_height
+ for rectangle in table_input.rectangles if include_rectangles else ():
+ if rectangle.segment_count != 5 or not (rectangle.fill_visible or rectangle.stroke_visible):
+ continue
+ rectangle_bbox = normalize_bbox(rectangle.bbox)
+ if rectangle_bbox is None:
+ continue
+ local_bbox = page_bbox_to_table_local(rectangle_bbox, table_bbox, angle)
+ if local_bbox is None:
+ continue
+ rect_width = local_bbox[2] - local_bbox[0]
+ rect_height = local_bbox[3] - local_bbox[1]
+ area_ratio = bbox_area(local_bbox) / table_area if table_area > 0 else 0.0
+ if rect_width <= snap_tolerance or rect_height <= snap_tolerance or area_ratio >= 0.85:
+ continue
+ fragments.extend(
+ [
+ _MergedRule("horizontal", local_bbox[1], local_bbox[0], local_bbox[2]),
+ _MergedRule("horizontal", local_bbox[3], local_bbox[0], local_bbox[2]),
+ _MergedRule("vertical", local_bbox[0], local_bbox[1], local_bbox[3]),
+ _MergedRule("vertical", local_bbox[2], local_bbox[1], local_bbox[3]),
+ ]
+ )
+ return fragments
+
+
+def _merge_rule_fragments(
+ fragments: list[_MergedRule],
+ snap_tolerance: float,
+ join_gap: float,
+) -> list[_MergedRule]:
+ """按方向和轴坐标吸附线段,再连接小间隙共线片段。"""
+
+ output: list[_MergedRule] = []
+ for orientation in ("horizontal", "vertical"):
+ oriented = [fragment for fragment in fragments if fragment.orientation == orientation]
+ coordinates = cluster_positions(
+ (fragment.coordinate for fragment in oriented),
+ snap_tolerance,
+ )
+ for coordinate in coordinates:
+ intervals = sorted(
+ (
+ min(fragment.start, fragment.end),
+ max(fragment.start, fragment.end),
+ )
+ for fragment in oriented
+ if abs(fragment.coordinate - coordinate) <= snap_tolerance
+ )
+ if not intervals:
+ continue
+ current_start, current_end = intervals[0]
+ for start, end in intervals[1:]:
+ if start <= current_end + join_gap:
+ current_end = max(current_end, end)
+ continue
+ output.append(_MergedRule(orientation, coordinate, current_start, current_end))
+ current_start, current_end = start, end
+ output.append(_MergedRule(orientation, coordinate, current_start, current_end))
+ return output
+
+
+def _repeated_long_rule_endpoints(
+ rules: list[_MergedRule],
+ axis_extent: float,
+ snap_tolerance: float,
+) -> list[float]:
+ """仅保留重复长线端点或接近表格外缘的外围轨道证据。"""
+
+ if not rules:
+ return []
+ maximum_length = max(rule.end - rule.start for rule in rules)
+ long_rules = [rule for rule in rules if rule.end - rule.start >= 0.80 * maximum_length]
+ required_support = max(2, math.ceil(0.50 * len(long_rules)))
+ positions = cluster_positions(
+ (endpoint for rule in long_rules for endpoint in (rule.start, rule.end)),
+ snap_tolerance,
+ )
+ output: list[float] = []
+ for position in positions:
+ support = sum(
+ min(
+ abs(rule.start - position),
+ abs(rule.end - position),
+ )
+ <= snap_tolerance
+ for rule in long_rules
+ )
+ if support >= required_support or position <= 2.0 * snap_tolerance or axis_extent - position <= 2.0 * snap_tolerance:
+ output.append(position)
+ return output
+
+
+def _infer_grid_tracks(
+ rules: list[_MergedRule],
+ snap_tolerance: float,
+ width: float,
+ height: float,
+ *,
+ prune_unsupported_horizontal: bool = False,
+) -> tuple[list[float], list[float], list[float]]:
+ """融合物理轴线与受重复门约束的端点,恢复开放外框轨道。"""
+
+ horizontal = [rule for rule in rules if rule.orientation == "horizontal"]
+ vertical = [rule for rule in rules if rule.orientation == "vertical"]
+ x_values = [rule.coordinate for rule in vertical]
+ x_values.extend(
+ _repeated_long_rule_endpoints(
+ horizontal,
+ width,
+ snap_tolerance,
+ )
+ )
+ provisional_x_tracks = cluster_positions(x_values, snap_tolerance)
+ removed_horizontal_tracks: list[float] = []
+ supported_horizontal = horizontal
+ if prune_unsupported_horizontal:
+ supported_horizontal, removed_horizontal_tracks = _filter_horizontal_track_creators(
+ horizontal,
+ provisional_x_tracks,
+ width,
+ snap_tolerance,
+ )
+ y_values = [rule.coordinate for rule in supported_horizontal]
+ y_values.extend(
+ _repeated_long_rule_endpoints(
+ vertical,
+ height,
+ snap_tolerance,
+ )
+ )
+ return (
+ provisional_x_tracks,
+ cluster_positions(y_values, snap_tolerance),
+ removed_horizontal_tracks,
+ )
+
+
+def _filter_horizontal_track_creators(
+ rules: list[_MergedRule],
+ x_tracks: list[float],
+ width: float,
+ snap_tolerance: float,
+) -> tuple[list[_MergedRule], list[float]]:
+ """剔除完全缩进在单元格内、不能形成真实横向轨道的装饰短线。"""
+
+ if len(x_tracks) < 2:
+ return rules, []
+ supported_coordinates: set[float] = set()
+ removed_coordinates: list[float] = []
+ for coordinate in cluster_positions(
+ (rule.coordinate for rule in rules),
+ snap_tolerance,
+ ):
+ coordinate_rules = [rule for rule in rules if abs(rule.coordinate - coordinate) <= snap_tolerance]
+ intervals = [(rule.start, rule.end) for rule in coordinate_rules]
+ full_width = covered_interval_ratio(intervals, 0.0, width)
+ band_supported = False
+ for left, right in zip(x_tracks, x_tracks[1:]):
+ if covered_interval_ratio(intervals, left, right) < SEPARATOR_COVERAGE_THRESHOLD:
+ continue
+ touches_left = any(
+ rule.start <= left + snap_tolerance and rule.end >= left - snap_tolerance for rule in coordinate_rules
+ )
+ touches_right = any(
+ rule.start <= right + snap_tolerance and rule.end >= right - snap_tolerance for rule in coordinate_rules
+ )
+ if touches_left and touches_right:
+ band_supported = True
+ break
+ if full_width >= SEPARATOR_COVERAGE_THRESHOLD or band_supported:
+ supported_coordinates.add(coordinate)
+ else:
+ removed_coordinates.append(coordinate)
+ return (
+ [
+ rule
+ for rule in rules
+ if any(abs(rule.coordinate - coordinate) <= snap_tolerance for coordinate in supported_coordinates)
+ ],
+ removed_coordinates,
+ )
+
+
+def _rule_indices_for_track(
+ tracks_rules: list[_MergedRule],
+ orientation: str,
+ track: _CanonicalTrack,
+ snap_tolerance: float,
+) -> set[int]:
+ """返回能够归属指定轨道的全部物理线索引。"""
+
+ return {
+ index
+ for index, rule in enumerate(tracks_rules)
+ if rule.orientation == orientation and any(abs(rule.coordinate - alias) <= snap_tolerance for alias in track.aliases)
+ }
+
+
+def _collapse_outer_duplicate_tracks(
+ tracks: list[_CanonicalTrack],
+ glyph_centers: list[float],
+ threshold: float,
+ extent: float,
+ rules: list[_MergedRule] | None,
+ orientation: str,
+ separator_extent: float,
+ snap_tolerance: float,
+ collapse_leading_edge: bool,
+) -> tuple[list[_CanonicalTrack], int, bool]:
+ """折叠外缘同一物理描边产生的重复轨,并保留独立双边界。"""
+
+ if rules is None or not orientation or len(tracks) < 2:
+ return tracks, 0, False
+ collapsed_count = 0
+ while len(tracks) >= 2:
+ candidate_indices = [len(tracks) - 2]
+ if collapse_leading_edge:
+ candidate_indices.insert(0, 0)
+ collapse_index: int | None = None
+ for index in candidate_indices:
+ left, right = tracks[index], tracks[index + 1]
+ if right.coordinate - left.coordinate > threshold or any(
+ left.coordinate < center < right.coordinate for center in glyph_centers
+ ):
+ continue
+ near_left_edge = right.coordinate <= max(
+ threshold,
+ 2.0 * snap_tolerance,
+ )
+ near_right_edge = extent - left.coordinate <= max(
+ threshold,
+ 2.0 * snap_tolerance,
+ )
+ if not (near_left_edge or near_right_edge):
+ continue
+ left_rules = _rule_indices_for_track(
+ rules,
+ orientation,
+ left,
+ snap_tolerance,
+ )
+ right_rules = _rule_indices_for_track(
+ rules,
+ orientation,
+ right,
+ snap_tolerance,
+ )
+ if left_rules and right_rules and left_rules.isdisjoint(right_rules):
+ continue
+ combined = _CanonicalTrack(
+ coordinate=float(
+ statistics.median(
+ (*left.aliases, *right.aliases),
+ )
+ ),
+ aliases=tuple(sorted({*left.aliases, *right.aliases})),
+ )
+ if (
+ combined.aliases[-1] - combined.aliases[0] > threshold
+ or _separator_coverage_for_track(
+ rules,
+ orientation,
+ combined,
+ 0.0,
+ separator_extent,
+ snap_tolerance,
+ )
+ < SEPARATOR_COVERAGE_THRESHOLD
+ ):
+ continue
+ collapse_index = index
+ break
+ if collapse_index is None:
+ break
+ left, right = tracks[collapse_index : collapse_index + 2]
+ aliases = tuple(sorted({*left.aliases, *right.aliases}))
+ if aliases[-1] - aliases[0] > threshold:
+ return tracks, collapsed_count, True
+ tracks[collapse_index : collapse_index + 2] = [
+ _CanonicalTrack(
+ coordinate=float(statistics.median(aliases)),
+ aliases=aliases,
+ )
+ ]
+ collapsed_count += 1
+ return tracks, collapsed_count, False
+
+
+def _canonicalize_axis_tracks(
+ positions: list[float],
+ glyph_centers: list[float],
+ threshold: float,
+ extent: float,
+ evidence_halo: float,
+ minimum_track_count: int,
+ *,
+ rules: list[_MergedRule] | None = None,
+ orientation: str = "",
+ separator_extent: float = 0.0,
+ snap_tolerance: float = 0.0,
+ preserve_double_boundary: bool = False,
+ collapse_narrow_bands: bool = True,
+ collapse_leading_edge: bool = True,
+) -> tuple[list[_CanonicalTrack], bool, int]:
+ """吸附外缘并折叠无字形占用的窄带,同时保留全部原始别名。"""
+
+ tracks = [
+ _CanonicalTrack(
+ coordinate=coordinate,
+ aliases=(coordinate,),
+ )
+ for coordinate in positions
+ ]
+ for edge in (0.0, extent):
+ halo_indices = [index for index, track in enumerate(tracks) if abs(track.coordinate - edge) <= evidence_halo]
+ if not halo_indices:
+ continue
+ closest_coordinate = min(
+ (tracks[index].coordinate for index in halo_indices),
+ key=lambda coordinate: abs(coordinate - edge),
+ )
+ edge_indices = [index for index in halo_indices if abs(tracks[index].coordinate - closest_coordinate) <= snap_tolerance]
+ aliases = tuple(
+ sorted(
+ {
+ edge,
+ *(alias for index in edge_indices for alias in tracks[index].aliases),
+ }
+ )
+ )
+ first_index = edge_indices[0]
+ tracks[first_index : edge_indices[-1] + 1] = [
+ _CanonicalTrack(
+ coordinate=edge,
+ aliases=aliases,
+ )
+ ]
+
+ tracks, outer_collapse_count, outer_alias_conflict = _collapse_outer_duplicate_tracks(
+ tracks,
+ glyph_centers,
+ threshold,
+ extent,
+ rules,
+ orientation,
+ separator_extent,
+ snap_tolerance,
+ collapse_leading_edge,
+ )
+ if outer_alias_conflict:
+ return tracks, True, outer_collapse_count
+
+ while collapse_narrow_bands and len(tracks) > minimum_track_count:
+ collapse_index = next(
+ (
+ index
+ for index, (left, right) in enumerate(zip(tracks, tracks[1:]))
+ if right.coordinate - left.coordinate <= threshold
+ and not any(left.coordinate < center < right.coordinate for center in glyph_centers)
+ and not (
+ preserve_double_boundary
+ and rules is not None
+ and _separator_coverage_for_track(
+ rules,
+ orientation,
+ left,
+ 0.0,
+ separator_extent,
+ snap_tolerance,
+ )
+ > 0.0
+ and _separator_coverage_for_track(
+ rules,
+ orientation,
+ right,
+ 0.0,
+ separator_extent,
+ snap_tolerance,
+ )
+ > 0.0
+ )
+ ),
+ None,
+ )
+ if collapse_index is None:
+ break
+ aliases = tuple(
+ sorted(
+ {
+ *tracks[collapse_index].aliases,
+ *tracks[collapse_index + 1].aliases,
+ }
+ )
+ )
+ if aliases[-1] - aliases[0] > threshold:
+ return tracks, True, outer_collapse_count
+ tracks[collapse_index : collapse_index + 2] = [
+ _CanonicalTrack(
+ coordinate=float(statistics.median(aliases)),
+ aliases=aliases,
+ )
+ ]
+ return tracks, False, outer_collapse_count
+
+
+def _canonical_track_coordinates(
+ tracks: list[_CanonicalTrack],
+) -> list[float]:
+ """提取规范轨道数值坐标,供网格 bbox 和稳定度计算使用。"""
+
+ return [track.coordinate for track in tracks]
+
+
+def _canonical_tracks_are_unique(
+ tracks: list[_CanonicalTrack],
+ rules: list[_MergedRule],
+ orientation: str,
+ snap_tolerance: float,
+) -> bool:
+ """校验每条物理线最多只能归属一个规范轨道别名集合。"""
+
+ for rule in rules:
+ if rule.orientation != orientation:
+ continue
+ matching_tracks = sum(
+ any(abs(rule.coordinate - alias) <= snap_tolerance for alias in track.aliases) for track in tracks
+ )
+ if matching_tracks > 1:
+ return False
+ return True
+
+
+def _separator_coverage_for_track(
+ rules: list[_MergedRule],
+ orientation: str,
+ track: _CanonicalTrack,
+ start: float,
+ end: float,
+ snap_tolerance: float,
+) -> float:
+ """按规范轨道全部 alias 合并计算 separator 覆盖率。"""
+
+ intervals = [
+ (rule.start, rule.end)
+ for rule in rules
+ if rule.orientation == orientation and any(abs(rule.coordinate - alias) <= snap_tolerance for alias in track.aliases)
+ ]
+ return covered_interval_ratio(intervals, start, end)
+
+
+def _rect_lattice_is_repeated(
+ rules: list[_MergedRule],
+ x_tracks: list[float],
+ y_tracks: list[float],
+ snap_tolerance: float,
+) -> bool:
+ """要求矩形边缘在二维晶格中重复且覆盖至少八成理论边界。"""
+
+ rows = len(y_tracks) - 1
+ cols = len(x_tracks) - 1
+ if rows < 2 or cols < 2:
+ return False
+ segment_present: list[bool] = []
+ vertical_repetitions: list[int] = []
+ for boundary_index, coordinate in enumerate(x_tracks):
+ repetitions = 0
+ for top, bottom in zip(y_tracks, y_tracks[1:]):
+ present = (
+ _separator_coverage(
+ rules,
+ "vertical",
+ coordinate,
+ top,
+ bottom,
+ snap_tolerance,
+ )
+ >= SEPARATOR_COVERAGE_THRESHOLD
+ )
+ segment_present.append(present)
+ repetitions += int(present)
+ if 0 < boundary_index < len(x_tracks) - 1:
+ vertical_repetitions.append(repetitions)
+ horizontal_repetitions: list[int] = []
+ for boundary_index, coordinate in enumerate(y_tracks):
+ repetitions = 0
+ for left, right in zip(x_tracks, x_tracks[1:]):
+ present = (
+ _separator_coverage(
+ rules,
+ "horizontal",
+ coordinate,
+ left,
+ right,
+ snap_tolerance,
+ )
+ >= SEPARATOR_COVERAGE_THRESHOLD
+ )
+ segment_present.append(present)
+ repetitions += int(present)
+ if 0 < boundary_index < len(y_tracks) - 1:
+ horizontal_repetitions.append(repetitions)
+ coverage = sum(segment_present) / len(segment_present) if segment_present else 0.0
+ return (
+ coverage >= SEPARATOR_COVERAGE_THRESHOLD
+ and any(count >= 2 for count in vertical_repetitions)
+ and any(count >= 2 for count in horizontal_repetitions)
+ )
+
+
+def _separator_coverage(
+ rules: list[_MergedRule],
+ orientation: str,
+ coordinate: float,
+ start: float,
+ end: float,
+ snap_tolerance: float,
+) -> float:
+ """计算指定潜在隔断被同轴物理线段覆盖的比例。"""
+
+ intervals = [
+ (rule.start, rule.end)
+ for rule in rules
+ if rule.orientation == orientation and abs(rule.coordinate - coordinate) <= snap_tolerance
+ ]
+ return covered_interval_ratio(intervals, start, end)
+
+
+def _grid_index(row: int, col: int, cols: int) -> int:
+ """把二维原子格坐标转换为并查集线性索引。"""
+
+ return row * cols + col
+
+
+def _build_component_specs(
+ union_find: _UnionFind,
+ rows: int,
+ cols: int,
+ x_tracks: list[float],
+ y_tracks: list[float],
+) -> tuple[GridCellSpec, ...] | None:
+ """把原子格连通分量转成矩形逻辑单元格,非矩形分量整体拒绝。"""
+
+ components: dict[int, list[tuple[int, int]]] = {}
+ for row in range(rows):
+ for col in range(cols):
+ root = union_find.find(_grid_index(row, col, cols))
+ components.setdefault(root, []).append((row, col))
+ specs: list[GridCellSpec] = []
+ for positions in components.values():
+ row_values = [item[0] for item in positions]
+ col_values = [item[1] for item in positions]
+ min_row, max_row = min(row_values), max(row_values)
+ min_col, max_col = min(col_values), max(col_values)
+ expected_size = (max_row - min_row + 1) * (max_col - min_col + 1)
+ if len(positions) != expected_size:
+ return None
+ specs.append(
+ GridCellSpec(
+ row=min_row,
+ col=min_col,
+ rowspan=max_row - min_row + 1,
+ colspan=max_col - min_col + 1,
+ bbox=(
+ x_tracks[min_col],
+ y_tracks[min_row],
+ x_tracks[max_col + 1],
+ y_tracks[max_row + 1],
+ ),
+ )
+ )
+ return tuple(sorted(specs, key=lambda item: (item.row, item.col)))
+
+
+def _occupied_text_rows(
+ text: NativeTableText,
+ y_tracks: list[float],
+) -> set[int]:
+ """返回至少包含一个视觉文本行中心的物理行索引。"""
+
+ occupied_rows: set[int] = set()
+ for row in text.rows:
+ center_y = (row.bbox[1] + row.bbox[3]) / 2.0
+ for row_index, (top, bottom) in enumerate(zip(y_tracks, y_tracks[1:])):
+ if top <= center_y <= bottom:
+ occupied_rows.add(row_index)
+ break
+ return occupied_rows
+
+
+def _line_grid_row_evidence(
+ rules: list[_MergedRule],
+ x_tracks: list[_CanonicalTrack],
+ y_tracks: list[_CanonicalTrack],
+ text: NativeTableText,
+ snap_tolerance: float,
+ minimum_row_height: float,
+ local_width: float,
+) -> tuple[_PhysicalRowEvidence, ...]:
+ """计算 line-grid 每个原子行的独立物理封闭证据。"""
+
+ left = x_tracks[0].coordinate
+ right = x_tracks[-1].coordinate
+ evidence: list[_PhysicalRowEvidence] = []
+ for row_index, (top_track, bottom_track) in enumerate(zip(y_tracks, y_tracks[1:])):
+ top = top_track.coordinate
+ bottom = bottom_track.coordinate
+ top_coverage = _separator_coverage_for_track(
+ rules,
+ "horizontal",
+ top_track,
+ left,
+ right,
+ snap_tolerance,
+ )
+ bottom_coverage = _separator_coverage_for_track(
+ rules,
+ "horizontal",
+ bottom_track,
+ left,
+ right,
+ snap_tolerance,
+ )
+ left_coverage = _separator_coverage_for_track(
+ rules,
+ "vertical",
+ x_tracks[0],
+ top,
+ bottom,
+ snap_tolerance,
+ )
+ right_coverage = _separator_coverage_for_track(
+ rules,
+ "vertical",
+ x_tracks[-1],
+ top,
+ bottom,
+ snap_tolerance,
+ )
+ endpoint_support = min(top_coverage, bottom_coverage)
+ if left <= 2.0 * snap_tolerance:
+ left_coverage = max(left_coverage, endpoint_support)
+ if local_width - right <= 2.0 * snap_tolerance:
+ right_coverage = max(right_coverage, endpoint_support)
+ glyph_crossing = any(
+ glyph.bbox[1] < bottom and glyph.bbox[3] > top and not (top <= (glyph.bbox[1] + glyph.bbox[3]) / 2.0 <= bottom)
+ for glyph in text.glyphs
+ )
+ evidence.append(
+ _PhysicalRowEvidence(
+ row=row_index,
+ top_coverage=top_coverage,
+ bottom_coverage=bottom_coverage,
+ left_coverage=left_coverage,
+ right_coverage=right_coverage,
+ height_ratio=min(
+ 1.0,
+ (bottom - top) / max(minimum_row_height, 0.1),
+ ),
+ glyph_crossing=glyph_crossing,
+ )
+ )
+ return tuple(evidence)
+
+
+def _single_row_line_grid_evidence(
+ rules: list[_MergedRule],
+ x_tracks: list[_CanonicalTrack],
+ y_tracks: list[_CanonicalTrack],
+ text: NativeTableText,
+ snap_tolerance: float,
+ minimum_row_height: float,
+) -> _SingleRowEvidence:
+ """校验单物理行候选的上下外框及每一条纵向边界。"""
+
+ top_track, bottom_track = y_tracks
+ top = top_track.coordinate
+ bottom = bottom_track.coordinate
+ left = x_tracks[0].coordinate
+ right = x_tracks[-1].coordinate
+ top_coverage = _separator_coverage_for_track(
+ rules,
+ "horizontal",
+ top_track,
+ left,
+ right,
+ snap_tolerance,
+ )
+ bottom_coverage = _separator_coverage_for_track(
+ rules,
+ "horizontal",
+ bottom_track,
+ left,
+ right,
+ snap_tolerance,
+ )
+ vertical_coverages = tuple(
+ _separator_coverage_for_track(
+ rules,
+ "vertical",
+ track,
+ top,
+ bottom,
+ snap_tolerance,
+ )
+ for track in x_tracks
+ )
+ glyph_crossing = any(glyph.bbox[0] < track.coordinate < glyph.bbox[2] for glyph in text.glyphs for track in x_tracks[1:-1])
+ return _SingleRowEvidence(
+ top_coverage=top_coverage,
+ bottom_coverage=bottom_coverage,
+ vertical_coverages=vertical_coverages,
+ height_ratio=min(
+ 1.0,
+ (bottom - top) / max(minimum_row_height, 0.1),
+ ),
+ glyph_crossing=glyph_crossing,
+ )
+
+
+def _single_column_line_grid_evidence(
+ rules: list[_MergedRule],
+ x_tracks: list[_CanonicalTrack],
+ y_tracks: list[_CanonicalTrack],
+ text: NativeTableText,
+ snap_tolerance: float,
+ minimum_row_height: float,
+) -> _SingleColumnEvidence:
+ """校验多行单列表单的全部横边和左右连续外框。"""
+
+ left_track, right_track = x_tracks
+ top = y_tracks[0].coordinate
+ bottom = y_tracks[-1].coordinate
+ horizontal_coverages = tuple(
+ _separator_coverage_for_track(
+ rules,
+ "horizontal",
+ track,
+ left_track.coordinate,
+ right_track.coordinate,
+ snap_tolerance,
+ )
+ for track in y_tracks
+ )
+ left_coverage = _separator_coverage_for_track(
+ rules,
+ "vertical",
+ left_track,
+ top,
+ bottom,
+ snap_tolerance,
+ )
+ right_coverage = _separator_coverage_for_track(
+ rules,
+ "vertical",
+ right_track,
+ top,
+ bottom,
+ snap_tolerance,
+ )
+ minimum_height_ratio = min(
+ (
+ min(
+ 1.0,
+ (current.coordinate - previous.coordinate) / max(minimum_row_height, 0.1),
+ )
+ for previous, current in zip(y_tracks, y_tracks[1:])
+ ),
+ default=0.0,
+ )
+ glyph_crossing = any(glyph.bbox[1] < track.coordinate < glyph.bbox[3] for glyph in text.glyphs for track in y_tracks[1:-1])
+ return _SingleColumnEvidence(
+ horizontal_coverages=horizontal_coverages,
+ left_coverage=left_coverage,
+ right_coverage=right_coverage,
+ minimum_height_ratio=minimum_height_ratio,
+ glyph_crossing=glyph_crossing,
+ )
+
+
+def _text_grid_stability(
+ text: NativeTableText,
+ x_tracks: list[float],
+ y_tracks: list[float],
+ physically_verified_rows: set[int] | None = None,
+) -> tuple[float, float]:
+ """衡量视觉文本行和文本项对推断行列轨道的占用稳定性。"""
+
+ occupied_rows = _occupied_text_rows(text, y_tracks)
+ supported_rows = occupied_rows | (physically_verified_rows or set())
+ occupied_cols: set[int] = set()
+ for row in text.rows:
+ for token in row.tokens:
+ center_x = (token.bbox[0] + token.bbox[2]) / 2.0
+ for col_index, (left, right) in enumerate(zip(x_tracks, x_tracks[1:])):
+ if left <= center_x <= right:
+ occupied_cols.add(col_index)
+ break
+ row_denominator = min(
+ len(y_tracks) - 1,
+ max(1, len(text.rows)),
+ )
+ col_denominator = min(
+ len(x_tracks) - 1,
+ max((len(row.tokens) for row in text.rows), default=1),
+ )
+ return (
+ min(1.0, len(supported_rows) / row_denominator),
+ min(1.0, len(occupied_cols) / col_denominator),
+ )
+
+
+def _looks_like_single_column_tracks(
+ x_tracks: list[float],
+ local_width: float,
+ edge_band: float,
+) -> bool:
+ """判断初始 X 轨是否全部属于单列表单的左右外缘。"""
+
+ return (
+ len(x_tracks) >= 2
+ and local_width > 0
+ and all(min(abs(track), abs(local_width - track)) <= edge_band for track in x_tracks)
+ )
+
+
+def _build_vector_candidate(
+ table_input: NativeTableInput,
+ text: NativeTableText,
+ *,
+ include_drawing: bool,
+ include_rectangles: bool,
+ evidence_label: str,
+ prune_unsupported_horizontal: bool = False,
+ diagnostics: dict[str, Any] | None = None,
+) -> NativeTableCandidate | None:
+ """按单一证据来源构造一个显式 rowspan/colspan 候选。"""
+
+ if diagnostics is not None:
+ diagnostics["evidence"] = evidence_label
+
+ def reject(gate: str) -> None:
+ """记录当前假设的首个拒绝门并返回空候选。"""
+
+ if diagnostics is not None:
+ diagnostics["first_rejection_gate"] = gate
+ return None
+
+ snap_tolerance = clamp(
+ 0.08 * text.median_glyph_height,
+ 0.5,
+ 2.5,
+ )
+ join_gap = clamp(
+ 0.40 * text.median_glyph_height,
+ 2.0,
+ 8.0,
+ )
+ configured_evidence_halo = (
+ clamp(
+ 0.25 * text.median_glyph_height,
+ 1.0,
+ 3.0,
+ )
+ if include_drawing and not include_rectangles
+ else 0.0
+ )
+ table_bbox = normalize_bbox(table_input.table_bbox)
+ if table_bbox is None:
+ return reject("table_geometry")
+ local_width, local_height = table_local_size(
+ table_bbox,
+ normalize_angle(table_input.angle),
+ )
+ exact_fragments = _local_rule_fragments(
+ table_input,
+ snap_tolerance,
+ include_drawing=include_drawing,
+ include_rectangles=include_rectangles,
+ evidence_halo=0.0,
+ )
+ if not exact_fragments or len(exact_fragments) > MAX_PRIMITIVES_PER_TABLE:
+ return reject("raw_fragments")
+ exact_rules = _merge_rule_fragments(
+ exact_fragments,
+ snap_tolerance,
+ join_gap,
+ )
+ exact_x_tracks, exact_y_tracks, _removed = _infer_grid_tracks(
+ exact_rules,
+ snap_tolerance,
+ local_width,
+ local_height,
+ )
+ # 多行表格保持原始 bbox 裁剪;halo 只服务可能退化为单物理行的
+ # 边界片段,避免吸入相邻行或页外端点改变既有拓扑。
+ single_column_halo_hint = (
+ include_drawing
+ and not include_rectangles
+ and len(exact_y_tracks) >= 3
+ and _looks_like_single_column_tracks(
+ exact_x_tracks,
+ local_width,
+ max(3.0 * configured_evidence_halo, 2.0),
+ )
+ )
+ evidence_halo = (
+ configured_evidence_halo
+ if configured_evidence_halo > 0
+ and (
+ single_column_halo_hint
+ or len(exact_y_tracks) == 2
+ or (
+ len(exact_y_tracks) == 3
+ and min(
+ current - previous
+ for previous, current in zip(
+ exact_y_tracks,
+ exact_y_tracks[1:],
+ )
+ )
+ <= 0.75 * text.median_glyph_height
+ )
+ )
+ else 0.0
+ )
+ if evidence_halo > 0:
+ raw_fragments = _local_rule_fragments(
+ table_input,
+ snap_tolerance,
+ include_drawing=include_drawing,
+ include_rectangles=include_rectangles,
+ evidence_halo=evidence_halo,
+ )
+ rules = _merge_rule_fragments(
+ raw_fragments,
+ snap_tolerance,
+ join_gap,
+ )
+ else:
+ raw_fragments = exact_fragments
+ rules = exact_rules
+ if diagnostics is not None:
+ diagnostics["raw_fragment_count"] = len(raw_fragments)
+ inferred_x_tracks, inferred_y_tracks, removed_horizontal_tracks = _infer_grid_tracks(
+ rules,
+ snap_tolerance,
+ local_width,
+ local_height,
+ prune_unsupported_horizontal=prune_unsupported_horizontal,
+ )
+ if diagnostics is not None:
+ diagnostics["track_hypothesis"] = "supported" if prune_unsupported_horizontal else "raw"
+ diagnostics["evidence_halo"] = evidence_halo
+ diagnostics["removed_horizontal_tracks"] = removed_horizontal_tracks
+ diagnostics["inferred_tracks"] = {
+ "x": len(inferred_x_tracks),
+ "y": len(inferred_y_tracks),
+ }
+ if (
+ include_rectangles
+ and not include_drawing
+ and not _rect_lattice_is_repeated(
+ rules,
+ inferred_x_tracks,
+ inferred_y_tracks,
+ snap_tolerance,
+ )
+ ):
+ return reject("rect_lattice")
+ line_widths = [rule.width for rule in table_input.drawing_lines if rule.width > 0]
+ median_line_width = float(statistics.median(line_widths)) if line_widths else 0.0
+ narrow_empty_threshold = max(
+ 0.75 * text.median_glyph_height,
+ 3.0 * median_line_width,
+ )
+ glyph_centers_x = [(glyph.bbox[0] + glyph.bbox[2]) / 2.0 for glyph in text.glyphs]
+ glyph_centers_y = [(glyph.bbox[1] + glyph.bbox[3]) / 2.0 for glyph in text.glyphs]
+ canonical_x_tracks, x_alias_conflict, outer_x_collapses = _canonicalize_axis_tracks(
+ inferred_x_tracks,
+ glyph_centers_x,
+ narrow_empty_threshold,
+ local_width,
+ evidence_halo,
+ 3,
+ rules=rules,
+ orientation="vertical",
+ separator_extent=local_height,
+ snap_tolerance=snap_tolerance,
+ )
+ canonical_y_tracks, y_alias_conflict, outer_y_collapses = _canonicalize_axis_tracks(
+ inferred_y_tracks,
+ glyph_centers_y,
+ narrow_empty_threshold,
+ local_height,
+ evidence_halo,
+ 2,
+ rules=rules,
+ orientation="horizontal",
+ separator_extent=local_width,
+ snap_tolerance=snap_tolerance,
+ preserve_double_boundary=True,
+ collapse_narrow_bands=len(exact_y_tracks) <= 3,
+ collapse_leading_edge=False,
+ )
+ if (
+ x_alias_conflict
+ or y_alias_conflict
+ or not _canonical_tracks_are_unique(
+ canonical_x_tracks,
+ rules,
+ "vertical",
+ snap_tolerance,
+ )
+ or not _canonical_tracks_are_unique(
+ canonical_y_tracks,
+ rules,
+ "horizontal",
+ snap_tolerance,
+ )
+ ):
+ return reject("canonical_alias")
+ x_tracks = _canonical_track_coordinates(canonical_x_tracks)
+ y_tracks = _canonical_track_coordinates(canonical_y_tracks)
+ if diagnostics is not None:
+ diagnostics["canonical_tracks"] = [
+ {
+ "coordinate": track.coordinate,
+ "aliases": list(track.aliases),
+ }
+ for track in canonical_x_tracks
+ ]
+ diagnostics["canonical_y_tracks"] = [
+ {
+ "coordinate": track.coordinate,
+ "aliases": list(track.aliases),
+ }
+ for track in canonical_y_tracks
+ ]
+ diagnostics["outer_track_collapses"] = {
+ "x": outer_x_collapses,
+ "y": outer_y_collapses,
+ }
+ if any(
+ right - left <= narrow_empty_threshold and not any(left < center < right for center in glyph_centers_x)
+ for left, right in zip(x_tracks, x_tracks[1:])
+ ):
+ return reject("remaining_narrow_track")
+ if any(
+ bottom_track.coordinate - top_track.coordinate <= narrow_empty_threshold
+ and not any(top_track.coordinate < center < bottom_track.coordinate for center in glyph_centers_y)
+ and _separator_coverage_for_track(
+ rules,
+ "horizontal",
+ top_track,
+ x_tracks[0],
+ x_tracks[-1],
+ snap_tolerance,
+ )
+ >= SEPARATOR_COVERAGE_THRESHOLD
+ and _separator_coverage_for_track(
+ rules,
+ "horizontal",
+ bottom_track,
+ x_tracks[0],
+ x_tracks[-1],
+ snap_tolerance,
+ )
+ >= SEPARATOR_COVERAGE_THRESHOLD
+ for top_track, bottom_track in zip(
+ canonical_y_tracks,
+ canonical_y_tracks[1:],
+ )
+ ):
+ return reject("remaining_narrow_track")
+ is_line_grid = include_drawing and not include_rectangles
+ is_single_row_shape = is_line_grid and len(y_tracks) == 2 and len(x_tracks) >= 3
+ is_single_column_shape = is_line_grid and len(x_tracks) == 2 and len(y_tracks) >= 3
+ if (
+ len(x_tracks) < (2 if is_single_column_shape else 3)
+ or len(y_tracks) < (2 if is_single_row_shape else 3)
+ or len(x_tracks) > MAX_TRACKS_PER_AXIS
+ or len(y_tracks) > MAX_TRACKS_PER_AXIS
+ ):
+ return reject("track_count")
+ rows = len(y_tracks) - 1
+ cols = len(x_tracks) - 1
+ if rows * cols > MAX_ATOMIC_CELLS:
+ return reject("atomic_cell_limit")
+
+ union_find = _UnionFind(rows * cols)
+ separator_decisions: list[float] = []
+ ambiguous_separator_count = 0
+ alias_separator_recoveries = 0
+ y_alias_separator_recoveries = 0
+ alias_affected_rows: set[int] = set()
+ for row in range(rows):
+ for boundary_index in range(1, len(canonical_x_tracks) - 1):
+ track = canonical_x_tracks[boundary_index]
+ strict_coverage = _separator_coverage(
+ rules,
+ "vertical",
+ track.coordinate,
+ y_tracks[row],
+ y_tracks[row + 1],
+ snap_tolerance,
+ )
+ coverage = _separator_coverage_for_track(
+ rules,
+ "vertical",
+ track,
+ y_tracks[row],
+ y_tracks[row + 1],
+ snap_tolerance,
+ )
+ if (
+ len(track.aliases) > 1
+ and strict_coverage <= 1.0 - SEPARATOR_COVERAGE_THRESHOLD
+ and coverage >= SEPARATOR_COVERAGE_THRESHOLD
+ ):
+ alias_separator_recoveries += 1
+ alias_affected_rows.add(row)
+ separator_decisions.append(max(coverage, 1.0 - coverage))
+ if coverage <= 1.0 - SEPARATOR_COVERAGE_THRESHOLD:
+ union_find.union(
+ _grid_index(row, boundary_index - 1, cols),
+ _grid_index(row, boundary_index, cols),
+ )
+ elif coverage < SEPARATOR_COVERAGE_THRESHOLD:
+ ambiguous_separator_count += 1
+ for boundary_index in range(1, len(canonical_y_tracks) - 1):
+ track = canonical_y_tracks[boundary_index]
+ for col in range(cols):
+ strict_coverage = _separator_coverage(
+ rules,
+ "horizontal",
+ track.coordinate,
+ x_tracks[col],
+ x_tracks[col + 1],
+ snap_tolerance,
+ )
+ coverage = _separator_coverage_for_track(
+ rules,
+ "horizontal",
+ track,
+ x_tracks[col],
+ x_tracks[col + 1],
+ snap_tolerance,
+ )
+ if (
+ len(track.aliases) > 1
+ and strict_coverage <= 1.0 - SEPARATOR_COVERAGE_THRESHOLD
+ and coverage >= SEPARATOR_COVERAGE_THRESHOLD
+ ):
+ y_alias_separator_recoveries += 1
+ if boundary_index > 0:
+ alias_affected_rows.add(boundary_index - 1)
+ if boundary_index < rows:
+ alias_affected_rows.add(boundary_index)
+ separator_decisions.append(max(coverage, 1.0 - coverage))
+ if coverage <= 1.0 - SEPARATOR_COVERAGE_THRESHOLD:
+ union_find.union(
+ _grid_index(boundary_index - 1, col, cols),
+ _grid_index(boundary_index, col, cols),
+ )
+ elif coverage < SEPARATOR_COVERAGE_THRESHOLD:
+ ambiguous_separator_count += 1
+
+ ambiguous_ratio = ambiguous_separator_count / len(separator_decisions) if separator_decisions else 0.0
+ if diagnostics is not None:
+ diagnostics["grid"] = {"rows": rows, "cols": cols}
+ diagnostics["ambiguous_separator_ratio"] = ambiguous_ratio
+ diagnostics["alias_separator_recoveries"] = alias_separator_recoveries
+ diagnostics["y_alias_separator_recoveries"] = y_alias_separator_recoveries
+ diagnostics["alias_affected_rows"] = sorted(alias_affected_rows)
+ if ambiguous_ratio > 0.05:
+ return reject("ambiguous_separator")
+
+ single_row_evidence: _SingleRowEvidence | None = None
+ if is_single_row_shape:
+ single_row_evidence = _single_row_line_grid_evidence(
+ rules,
+ canonical_x_tracks,
+ canonical_y_tracks,
+ text,
+ snap_tolerance,
+ narrow_empty_threshold,
+ )
+ if diagnostics is not None:
+ diagnostics["single_row_evidence"] = {
+ "reliability": single_row_evidence.reliability,
+ "confidence": single_row_evidence.confidence,
+ "verified": single_row_evidence.verified,
+ "top": single_row_evidence.top_coverage,
+ "bottom": single_row_evidence.bottom_coverage,
+ "vertical": list(single_row_evidence.vertical_coverages),
+ "height_ratio": single_row_evidence.height_ratio,
+ "glyph_crossing": single_row_evidence.glyph_crossing,
+ }
+ if not single_row_evidence.verified:
+ return reject("single_row_physical_evidence")
+
+ single_column_evidence: _SingleColumnEvidence | None = None
+ if is_single_column_shape:
+ single_column_evidence = _single_column_line_grid_evidence(
+ rules,
+ canonical_x_tracks,
+ canonical_y_tracks,
+ text,
+ snap_tolerance,
+ narrow_empty_threshold,
+ )
+ if diagnostics is not None:
+ diagnostics["single_column_evidence"] = {
+ "reliability": single_column_evidence.reliability,
+ "confidence": single_column_evidence.confidence,
+ "verified": single_column_evidence.verified,
+ "horizontal": list(single_column_evidence.horizontal_coverages),
+ "left": single_column_evidence.left_coverage,
+ "right": single_column_evidence.right_coverage,
+ "minimum_height_ratio": (single_column_evidence.minimum_height_ratio),
+ "glyph_crossing": single_column_evidence.glyph_crossing,
+ }
+ if not single_column_evidence.verified:
+ return reject("single_column_physical_evidence")
+
+ specs = _build_component_specs(
+ union_find,
+ rows,
+ cols,
+ x_tracks,
+ y_tracks,
+ )
+ if specs is None:
+ return reject("nonrectangular_topology")
+ maximum_row_cells = max(sum(spec.row <= row_index < spec.row + spec.rowspan for spec in specs) for row_index in range(rows))
+ maximum_col_cells = max(sum(spec.col <= col_index < spec.col + spec.colspan for spec in specs) for col_index in range(cols))
+ if (maximum_row_cells < 2 and not is_single_column_shape) or (maximum_col_cells < 2 and not is_single_row_shape):
+ return reject("degenerate_grid")
+ decisiveness = float(statistics.mean(separator_decisions)) if separator_decisions else 1.0
+ if single_row_evidence is not None:
+ decisiveness = max(
+ decisiveness,
+ single_row_evidence.confidence,
+ )
+ if single_column_evidence is not None:
+ decisiveness = max(
+ decisiveness,
+ single_column_evidence.confidence,
+ )
+ evidence_ratio = min(1.0, len(rules) / max(1, rows + cols))
+ structure_support = min(
+ decisiveness,
+ evidence_ratio,
+ 1.0 - ambiguous_ratio,
+ (single_row_evidence.confidence if single_row_evidence is not None else 1.0),
+ (single_column_evidence.confidence if single_column_evidence is not None else 1.0),
+ )
+ occupied_rows = _occupied_text_rows(text, y_tracks)
+ line_row_evidence: tuple[_PhysicalRowEvidence, ...] = ()
+ physically_verified_rows: set[int] = set()
+ if is_line_grid:
+ line_row_evidence = _line_grid_row_evidence(
+ rules,
+ canonical_x_tracks,
+ canonical_y_tracks,
+ text,
+ snap_tolerance,
+ narrow_empty_threshold,
+ local_width,
+ )
+ physically_verified_rows = {evidence.row for evidence in line_row_evidence if evidence.verified}
+ if diagnostics is not None:
+ diagnostics["physical_rows"] = [
+ {
+ "row": evidence.row,
+ "reliability": evidence.reliability,
+ "verified": evidence.verified,
+ "top": evidence.top_coverage,
+ "bottom": evidence.bottom_coverage,
+ "left": evidence.left_coverage,
+ "right": evidence.right_coverage,
+ "height_ratio": evidence.height_ratio,
+ "glyph_crossing": evidence.glyph_crossing,
+ }
+ for evidence in line_row_evidence
+ ]
+ row_stability, column_stability = _text_grid_stability(
+ text,
+ x_tracks,
+ y_tracks,
+ physically_verified_rows=(physically_verified_rows if is_line_grid else None),
+ )
+ collapsed_track_count = sum(len(track.aliases) > 1 for track in canonical_x_tracks)
+ collapsed_y_track_count = sum(len(track.aliases) > 1 for track in canonical_y_tracks)
+ maximum_alias_span = max(
+ (
+ track.aliases[-1] - track.aliases[0]
+ for track in (*canonical_x_tracks, *canonical_y_tracks)
+ if len(track.aliases) > 1
+ ),
+ default=0.0,
+ )
+ potential_blank_rows = sorted(set(range(rows)) - occupied_rows)
+ candidate = build_candidate(
+ source="vector_grid",
+ rows=rows,
+ cols=cols,
+ specs=specs,
+ text=text,
+ structure_support=structure_support,
+ row_stability=row_stability,
+ column_stability=column_stability,
+ issues=(
+ f"evidence={evidence_label}",
+ f"ambiguous_separator_ratio={ambiguous_ratio:.4f}",
+ f"collapsed_x_tracks={collapsed_track_count}",
+ f"collapsed_y_tracks={collapsed_y_track_count}",
+ f"alias_max_span={maximum_alias_span:.4f}",
+ f"alias_separator_recoveries={alias_separator_recoveries}",
+ f"y_alias_separator_recoveries={y_alias_separator_recoveries}",
+ f"single_row_line_grid={str(is_single_row_shape).lower()}",
+ f"single_column_line_grid={str(is_single_column_shape).lower()}",
+ "single_row_reliability="
+ + (f"{single_row_evidence.reliability:.4f}" if single_row_evidence is not None else "n/a"),
+ "single_row_confidence=" + (f"{single_row_evidence.confidence:.4f}" if single_row_evidence is not None else "n/a"),
+ "single_column_reliability="
+ + (f"{single_column_evidence.reliability:.4f}" if single_column_evidence is not None else "n/a"),
+ "single_column_confidence="
+ + (f"{single_column_evidence.confidence:.4f}" if single_column_evidence is not None else "n/a"),
+ "physical_blank_rows=" + ",".join(str(row) for row in potential_blank_rows if row in physically_verified_rows),
+ ),
+ allow_single_row=is_single_row_shape,
+ allow_single_column=is_single_column_shape,
+ )
+ if candidate is None:
+ return reject("candidate_hard_gate")
+ if is_single_row_shape and (candidate.text_capture < 1.0 or candidate.order_consistency < 1.0):
+ return reject("single_row_text_integrity")
+ if is_single_column_shape and (candidate.text_capture < 1.0 or candidate.order_consistency < 1.0):
+ return reject("single_column_text_integrity")
+ row_content_support = [
+ sum(bool(cell.content.strip()) for cell in candidate.cells if cell.row <= row_index < cell.row + cell.rowspan)
+ for row_index in range(candidate.rows)
+ ]
+ empty_rows = {row_index for row_index, support in enumerate(row_content_support) if support == 0}
+ if empty_rows and len(text.rows) >= 2:
+ if (
+ not is_line_grid
+ or not empty_rows.isdisjoint(alias_affected_rows)
+ or not empty_rows.issubset(physically_verified_rows)
+ ):
+ if diagnostics is not None:
+ diagnostics["empty_rows"] = sorted(empty_rows)
+ return reject("empty_row")
+ if diagnostics is not None:
+ diagnostics["first_rejection_gate"] = None
+ diagnostics["score"] = candidate.score
+ diagnostics["empty_rows"] = sorted(empty_rows)
+ return candidate
+
+
+def build_vector_candidates(
+ table_input: NativeTableInput,
+ text: NativeTableText,
+ diagnostics: list[dict[str, Any]] | None = None,
+) -> list[NativeTableCandidate]:
+ """分别从 drawing 中心线和矩形晶格生成矢量网格候选。"""
+
+ candidates: list[NativeTableCandidate] = []
+ raw_line_diagnostics: dict[str, Any] | None = {} if diagnostics is not None else None
+ line_candidate = _build_vector_candidate(
+ table_input,
+ text,
+ include_drawing=True,
+ include_rectangles=False,
+ evidence_label="line_grid",
+ diagnostics=raw_line_diagnostics,
+ )
+ line_hypotheses = [raw_line_diagnostics] if raw_line_diagnostics is not None else []
+ selected_line_diagnostics = raw_line_diagnostics
+ if line_candidate is None and len(line_hypotheses) < MAX_TRACK_HYPOTHESES:
+ supported_line_diagnostics: dict[str, Any] | None = {} if diagnostics is not None else None
+ supported_line_candidate = _build_vector_candidate(
+ table_input,
+ text,
+ include_drawing=True,
+ include_rectangles=False,
+ evidence_label="line_grid",
+ prune_unsupported_horizontal=True,
+ diagnostics=supported_line_diagnostics,
+ )
+ if supported_line_diagnostics is not None:
+ removed_tracks = supported_line_diagnostics.get(
+ "removed_horizontal_tracks",
+ [],
+ )
+ if removed_tracks:
+ line_hypotheses.append(supported_line_diagnostics)
+ selected_line_diagnostics = supported_line_diagnostics
+ if supported_line_candidate is not None:
+ line_candidate = supported_line_candidate
+ selected_line_diagnostics = supported_line_diagnostics
+ if diagnostics is not None and selected_line_diagnostics is not None:
+ line_record = dict(selected_line_diagnostics)
+ line_record["track_hypotheses"] = [dict(hypothesis) for hypothesis in line_hypotheses if hypothesis is not None]
+ diagnostics.append(line_record)
+ if line_candidate is not None:
+ candidates.append(line_candidate)
+ rect_diagnostics: dict[str, Any] | None = {} if diagnostics is not None else None
+ rect_candidate = _build_vector_candidate(
+ table_input,
+ text,
+ include_drawing=False,
+ include_rectangles=True,
+ evidence_label="rect_grid",
+ diagnostics=rect_diagnostics,
+ )
+ if diagnostics is not None and rect_diagnostics is not None:
+ diagnostics.append(rect_diagnostics)
+ if rect_candidate is not None:
+ candidates.append(rect_candidate)
+ return candidates
+
+
+def diagnose_vector_candidate_builds(
+ table_input: NativeTableInput,
+ text: NativeTableText,
+) -> tuple[dict[str, Any], ...]:
+ """返回 line/rect 假设真实首个拒绝门和物理证据。"""
+
+ diagnostics: list[dict[str, Any]] = []
+ build_vector_candidates(
+ table_input,
+ text,
+ diagnostics=diagnostics,
+ )
+ return tuple(diagnostics)
+
+
+__all__ = [
+ "MAX_ATOMIC_CELLS",
+ "MAX_PRIMITIVES_PER_TABLE",
+ "MAX_TRACKS_PER_AXIS",
+ "build_vector_candidates",
+]
diff --git a/mineru/utils/pdf_document.py b/mineru/utils/pdf_document.py
index 826beec6..3c40dddd 100644
--- a/mineru/utils/pdf_document.py
+++ b/mineru/utils/pdf_document.py
@@ -144,6 +144,11 @@ class PDFPage:
return self.pdf_doc.get_page_drawing_lines(self._idx)
+ def get_path_infos(self) -> list[PDFPathInfo]:
+ """读取当前页及嵌套 Form 中已规范到视觉页面坐标的 Path 摘要。"""
+
+ return self.pdf_doc.get_page_path_infos(self._idx)
+
def get_link_annotations(self) -> list[PDFLinkAnnotation]:
"""读取当前页已规范到视觉页面坐标的外部 URI Link 注解。"""
diff --git a/tests/fixtures/evaluate_native_pdf_table_manifest.py b/tests/fixtures/evaluate_native_pdf_table_manifest.py
new file mode 100644
index 00000000..76eced9f
--- /dev/null
+++ b/tests/fixtures/evaluate_native_pdf_table_manifest.py
@@ -0,0 +1,304 @@
+# Copyright (c) Opendatalab. All rights reserved.
+"""运行外部跨页 PDF 真值 manifest 的 Native Table 发布门。"""
+
+from __future__ import annotations
+
+import argparse
+import hashlib
+import json
+import statistics
+import time
+from collections import defaultdict
+from pathlib import Path, PureWindowsPath
+from typing import Any
+
+from mineru.utils.native_pdf_table import (
+ NativeTableInput,
+ coerce_native_table_rectangles,
+ coerce_native_table_rules,
+ recover_native_pdf_table,
+)
+from mineru.utils.native_pdf_table.engine import diagnose_native_pdf_table
+from mineru.utils.pdf_document import PDFDocument
+
+_DEFAULT_SOURCE_ROOT = Path(__file__).resolve().parents[1] / "unittest" / "pdfs" / "native_pdf_tables"
+
+
+def _validate_portable_manifest(manifest: dict[str, Any]) -> None:
+ """拒绝把语料根目录或主机绝对路径固化进版本化 manifest。"""
+
+ forbidden_root_keys = {"source_root", "source_root_hint"}
+ persisted_root_keys = forbidden_root_keys.intersection(manifest)
+ if persisted_root_keys:
+ keys = ", ".join(sorted(persisted_root_keys))
+ raise ValueError(f"manifest 不得保存语料根目录字段: {keys}")
+
+ for collection_name in ("entries", "flash_targets"):
+ for entry_index, entry in enumerate(
+ manifest.get(collection_name, []),
+ ):
+ filename = str(entry["file"])
+ path = Path(filename)
+ if path.is_absolute() or PureWindowsPath(filename).is_absolute() or ".." in path.parts:
+ raise ValueError(
+ f"manifest {collection_name}[{entry_index}].file 必须是 source root 下的安全相对路径: {filename}"
+ )
+
+
+def _result_signature(result: Any) -> dict[str, Any] | None:
+ """把原生结构结果转换为 manifest 可比较的稳定签名。"""
+
+ if result is None:
+ return None
+ return {
+ "rows": result.rows,
+ "cols": result.cols,
+ "span_signature": [
+ [cell.row, cell.col, cell.rowspan, cell.colspan] for cell in result.cells if cell.rowspan > 1 or cell.colspan > 1
+ ],
+ "text_sha256": hashlib.sha256("\n".join(cell.content for cell in result.cells).encode("utf-8")).hexdigest(),
+ }
+
+
+def _evaluate_entry(
+ document: PDFDocument,
+ entry: dict[str, Any],
+ page_cache: dict[int, tuple[Any, ...]],
+) -> tuple[dict[str, Any] | None, float, dict[str, Any]]:
+ """运行一个 manifest 表格并返回结构签名和耗时。"""
+
+ page_index = int(entry["page_index"])
+ if page_index not in page_cache:
+ page = document[page_index]
+ page_cache[page_index] = (
+ page.size,
+ tuple(page.get_chars()),
+ coerce_native_table_rules(page.get_drawing_lines()),
+ coerce_native_table_rectangles(page.get_path_infos()),
+ )
+ page_size, chars, rules, rectangles = page_cache[page_index]
+ if "bbox_points" in entry:
+ point_bbox = tuple(float(value) for value in entry["bbox_points"])
+ else:
+ bbox = entry["bbox"]
+ # Low TXT 使用整数化 PDFPage 尺寸还原归一化 layout bbox;评测必须复现
+ # 同一生产坐标边界,避免亚点级外缘生成幽灵轨道。
+ production_page_size = (int(page_size[0]), int(page_size[1]))
+ point_bbox = tuple(
+ bbox[index] * (production_page_size[0] if index % 2 == 0 else production_page_size[1]) for index in range(4)
+ )
+ table_input = NativeTableInput(
+ table_bbox=point_bbox,
+ page_size=page_size,
+ angle=0,
+ chars=chars,
+ drawing_lines=rules,
+ rectangles=rectangles,
+ )
+ # 先执行一次不计时预热,避免 Python 首次路径和页面缓存抖动污染 p95。
+ recover_native_pdf_table(table_input)
+ started = time.perf_counter()
+ result = recover_native_pdf_table(table_input)
+ duration = time.perf_counter() - started
+ return (
+ _result_signature(result),
+ duration,
+ diagnose_native_pdf_table(table_input),
+ )
+
+
+def _entry_mismatch(
+ entry: dict[str, Any],
+ actual: dict[str, Any] | None,
+) -> tuple[str, bool]:
+ """比较一个真值条目的输出模式、拓扑和单元格文本哈希。"""
+
+ actual_output = "html" if actual is not None else "projection"
+ expected_output = entry["expected_output"]
+ mismatch = actual_output != expected_output
+ if actual is not None and expected_output == "html":
+ mismatch = mismatch or any(
+ actual[field] != entry[field]
+ for field in (
+ "rows",
+ "cols",
+ "span_signature",
+ "text_sha256",
+ )
+ )
+ return actual_output, mismatch
+
+
+def main() -> None:
+ """校验 HTML 覆盖率、结构真值、文本哈希和解析性能。"""
+
+ parser = argparse.ArgumentParser()
+ parser.add_argument(
+ "--source-root",
+ type=Path,
+ default=_DEFAULT_SOURCE_ROOT,
+ help="PDF 语料目录;默认使用仓库内 Native Table fixtures。",
+ )
+ parser.add_argument(
+ "--manifest",
+ type=Path,
+ default=Path("tests/fixtures/native_pdf_table_cross_page_manifest.json"),
+ )
+ parser.add_argument(
+ "--diagnostics-output",
+ type=Path,
+ help="可选写出逐表候选和首个拒绝门诊断。",
+ )
+ parser.add_argument(
+ "--skip-performance-gate",
+ action="store_true",
+ help="跳过易受共享 CI 负载影响的 p95 门,仅用于 pytest 功能回归。",
+ )
+ args = parser.parse_args()
+ manifest = json.loads(args.manifest.read_text(encoding="utf-8"))
+ _validate_portable_manifest(manifest)
+ entries_by_file: dict[str, list[dict[str, Any]]] = defaultdict(list)
+ for entry in manifest["entries"]:
+ entries_by_file[entry["file"]].append(entry)
+
+ target_mismatches: list[dict[str, Any]] = []
+ regression_mismatches: list[dict[str, Any]] = []
+ diagnostics: list[dict[str, Any]] = []
+ html_count = 0
+ target_html_count = 0
+ durations: list[float] = []
+ for filename, entries in entries_by_file.items():
+ with PDFDocument(str(args.source_root / filename)) as document:
+ page_cache: dict[int, tuple[Any, ...]] = {}
+ for entry in entries:
+ actual, duration, diagnostic = _evaluate_entry(
+ document,
+ entry,
+ page_cache,
+ )
+ diagnostics.append(
+ {
+ "scope": "corpus",
+ "file": filename,
+ "page_index": entry["page_index"],
+ "table_index": entry["table_index"],
+ "bbox": entry["bbox"],
+ "expected_output": entry["expected_output"],
+ **diagnostic,
+ }
+ )
+ durations.append(duration)
+ actual_output, mismatch = _entry_mismatch(entry, actual)
+ if actual_output == "html":
+ html_count += 1
+ is_target = entry["review_status"] == "target_verified"
+ if is_target and actual_output == "html":
+ target_html_count += 1
+ if mismatch:
+ mismatch_record = {
+ "file": filename,
+ "page_index": entry["page_index"],
+ "table_index": entry["table_index"],
+ "review_status": entry["review_status"],
+ "expected_output": entry["expected_output"],
+ "actual": actual,
+ }
+ if is_target:
+ target_mismatches.append(mismatch_record)
+ else:
+ regression_mismatches.append(mismatch_record)
+
+ flash_targets_by_file: dict[str, list[dict[str, Any]]] = defaultdict(list)
+ for entry in manifest.get("flash_targets", []):
+ flash_targets_by_file[entry["file"]].append(entry)
+ flash_target_html_count = 0
+ flash_target_mismatches: list[dict[str, Any]] = []
+ for filename, entries in flash_targets_by_file.items():
+ with PDFDocument(str(args.source_root / filename)) as document:
+ page_cache = {}
+ for entry in entries:
+ actual, duration, diagnostic = _evaluate_entry(
+ document,
+ entry,
+ page_cache,
+ )
+ diagnostics.append(
+ {
+ "scope": "flash_target",
+ "file": filename,
+ "page_index": entry["page_index"],
+ "table_index": entry["table_index"],
+ "bbox_points": entry["bbox_points"],
+ "expected_output": entry["expected_output"],
+ **diagnostic,
+ }
+ )
+ durations.append(duration)
+ actual_output, mismatch = _entry_mismatch(entry, actual)
+ if actual_output == "html":
+ flash_target_html_count += 1
+ if mismatch:
+ flash_target_mismatches.append(
+ {
+ "file": filename,
+ "page_index": entry["page_index"],
+ "table_index": entry["table_index"],
+ "expected_output": entry["expected_output"],
+ "actual": actual,
+ }
+ )
+
+ total = len(manifest["entries"])
+ target_total = sum(entry["review_status"] == "target_verified" for entry in manifest["entries"])
+ flash_target_total = len(manifest.get("flash_targets", []))
+ p95_milliseconds = 1000.0 * statistics.quantiles(durations, n=20)[18] if len(durations) >= 20 else 0.0
+ summary = {
+ "accuracy_scope": manifest["accuracy_scope"],
+ "tables": total,
+ "html": html_count,
+ "coverage": html_count / total if total else 0.0,
+ "target_tables": target_total,
+ "target_html": target_html_count,
+ "target_mismatches": len(target_mismatches),
+ "target_precision": ((target_html_count - len(target_mismatches)) / target_html_count if target_html_count else 0.0),
+ "regression_mismatches": len(regression_mismatches),
+ "flash_targets": flash_target_total,
+ "flash_target_html": flash_target_html_count,
+ "flash_target_mismatches": len(flash_target_mismatches),
+ "p95_milliseconds": p95_milliseconds,
+ }
+ result_payload = {
+ "summary": summary,
+ "target_mismatches": target_mismatches,
+ "regression_mismatches": regression_mismatches,
+ "flash_target_mismatches": flash_target_mismatches,
+ }
+ print(json.dumps(result_payload, ensure_ascii=False, indent=2))
+ if args.diagnostics_output is not None:
+ args.diagnostics_output.parent.mkdir(parents=True, exist_ok=True)
+ args.diagnostics_output.write_text(
+ json.dumps(
+ {
+ "summary": summary,
+ "tables": diagnostics,
+ },
+ ensure_ascii=False,
+ indent=2,
+ ),
+ encoding="utf-8",
+ )
+ if (
+ html_count != manifest["expected_html"]
+ or target_total != manifest["target_verified_tables"]
+ or target_html_count != target_total
+ or target_mismatches
+ or regression_mismatches
+ or flash_target_html_count != flash_target_total
+ or flash_target_mismatches
+ or (not args.skip_performance_gate and p95_milliseconds > manifest["performance_p95_limit_ms"])
+ ):
+ raise SystemExit(1)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/tests/fixtures/native_pdf_table_cross_page_manifest.json b/tests/fixtures/native_pdf_table_cross_page_manifest.json
new file mode 100644
index 00000000..0412bbe4
--- /dev/null
+++ b/tests/fixtures/native_pdf_table_cross_page_manifest.json
@@ -0,0 +1,8389 @@
+{
+ "schema_version": 5,
+ "manifest_version": "2026-08-25-v5-repository-fixtures",
+ "total_tables": 133,
+ "expected_html": 133,
+ "expected_projection": 0,
+ "performance_p95_limit_ms": 27.0,
+ "entries": [
+ {
+ "file": "conference_schedule_tables.pdf",
+ "page_index": 0,
+ "table_index": 0,
+ "bbox": [
+ 0.092,
+ 0.209,
+ 0.928,
+ 0.911
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 10,
+ "cols": 4,
+ "span_signature": [
+ [
+ 1,
+ 0,
+ 1,
+ 4
+ ],
+ [
+ 3,
+ 2,
+ 2,
+ 1
+ ],
+ [
+ 3,
+ 3,
+ 4,
+ 1
+ ],
+ [
+ 5,
+ 1,
+ 1,
+ 2
+ ],
+ [
+ 7,
+ 1,
+ 1,
+ 2
+ ],
+ [
+ 8,
+ 0,
+ 2,
+ 1
+ ]
+ ],
+ "text_sha256": "8b887f3be58a4bceac993857ec28c45f9639fa1d509d7391b9badd5576994ac7"
+ },
+ {
+ "file": "conference_schedule_tables.pdf",
+ "page_index": 1,
+ "table_index": 0,
+ "bbox": [
+ 0.093,
+ 0.089,
+ 0.928,
+ 0.895
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 5,
+ "cols": 4,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 5,
+ 1
+ ]
+ ],
+ "text_sha256": "e58fe41773b2f27073b3677aedd9a27e5eab6736a37ad83d5fa3a295ecd123b8"
+ },
+ {
+ "file": "conference_schedule_tables.pdf",
+ "page_index": 2,
+ "table_index": 0,
+ "bbox": [
+ 0.092,
+ 0.09,
+ 0.929,
+ 0.923
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 6,
+ "cols": 4,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 2,
+ 1,
+ 1,
+ 3
+ ],
+ [
+ 3,
+ 0,
+ 3,
+ 1
+ ]
+ ],
+ "text_sha256": "c78c7fa48096ffa6de29e492e2944bdfb06662a231e6c14f8bcb4ac348c73665"
+ },
+ {
+ "file": "conference_schedule_tables.pdf",
+ "page_index": 3,
+ "table_index": 0,
+ "bbox": [
+ 0.202,
+ 0.09,
+ 0.929,
+ 0.909
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 6,
+ "cols": 3,
+ "span_signature": [],
+ "text_sha256": "2f9f38231f92a729661344f5cfa7ef43f6c3a406920a2d8297e53d5b9b922f32"
+ },
+ {
+ "file": "conference_schedule_tables.pdf",
+ "page_index": 4,
+ "table_index": 0,
+ "bbox": [
+ 0.092,
+ 0.09,
+ 0.928,
+ 0.909
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 8,
+ "cols": 4,
+ "span_signature": [
+ [
+ 1,
+ 0,
+ 1,
+ 4
+ ],
+ [
+ 2,
+ 2,
+ 2,
+ 1
+ ],
+ [
+ 2,
+ 3,
+ 2,
+ 1
+ ],
+ [
+ 4,
+ 1,
+ 1,
+ 3
+ ],
+ [
+ 5,
+ 0,
+ 3,
+ 1
+ ]
+ ],
+ "text_sha256": "41a3d96e4d4740039d93989d015c413e766f0fe3933a770c4e2f7977bd4d3daa"
+ },
+ {
+ "file": "conference_schedule_tables.pdf",
+ "page_index": 5,
+ "table_index": 0,
+ "bbox": [
+ 0.158,
+ 0.09,
+ 0.931,
+ 0.913
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 6,
+ "cols": 4,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 6,
+ 1
+ ]
+ ],
+ "text_sha256": "bf13feeccd3514cfe4ec76f4f5b7ba962f301906b6252290795bf7ab0646f8d9"
+ },
+ {
+ "file": "conference_schedule_tables.pdf",
+ "page_index": 6,
+ "table_index": 0,
+ "bbox": [
+ 0.092,
+ 0.09,
+ 0.928,
+ 0.9
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 6,
+ "cols": 4,
+ "span_signature": [
+ [
+ 1,
+ 1,
+ 1,
+ 2
+ ],
+ [
+ 2,
+ 0,
+ 4,
+ 1
+ ]
+ ],
+ "text_sha256": "c898bbdc23b8a7aee415515c0e38241146b3df36757d6577c7c0eac6790a6f0d"
+ },
+ {
+ "file": "conference_schedule_tables.pdf",
+ "page_index": 7,
+ "table_index": 0,
+ "bbox": [
+ 0.092,
+ 0.09,
+ 0.929,
+ 0.919
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 6,
+ "cols": 4,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 5,
+ 1
+ ]
+ ],
+ "text_sha256": "5024e9352d3e89138773621157357488c4480919f465ef0858454f9696b523cc"
+ },
+ {
+ "file": "conference_schedule_tables.pdf",
+ "page_index": 8,
+ "table_index": 0,
+ "bbox": [
+ 0.092,
+ 0.089,
+ 0.928,
+ 0.918
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 6,
+ "cols": 4,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 6,
+ 1
+ ]
+ ],
+ "text_sha256": "e69c3d0532acbdcfc2d359de1e847222482fe228126cf5d5d2192faa17501412"
+ },
+ {
+ "file": "conference_schedule_tables.pdf",
+ "page_index": 9,
+ "table_index": 0,
+ "bbox": [
+ 0.092,
+ 0.09,
+ 0.928,
+ 0.718
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 3,
+ "cols": 4,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ]
+ ],
+ "text_sha256": "c7850b320840870b9ab233498cc42cfbfe10681428ea2b9795e1ea6405772e91"
+ },
+ {
+ "file": "manufacturing_facilities_cross_page_table.pdf",
+ "page_index": 0,
+ "table_index": 0,
+ "bbox": [
+ 0.046,
+ 0.149,
+ 0.952,
+ 0.69
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 13,
+ "cols": 15,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 2,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 3,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 4,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 5,
+ 1,
+ 4
+ ],
+ [
+ 0,
+ 9,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 10,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 11,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 12,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 13,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 14,
+ 2,
+ 1
+ ],
+ [
+ 2,
+ 0,
+ 9,
+ 1
+ ],
+ [
+ 2,
+ 1,
+ 9,
+ 1
+ ],
+ [
+ 2,
+ 2,
+ 9,
+ 1
+ ],
+ [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"file": "procurement_document_blank_page_tables.pdf",
+ "page_index": 2,
+ "table_index": 0,
+ "bbox": [
+ 0.169,
+ 0.501,
+ 0.828,
+ 0.596
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 2,
+ "cols": 5,
+ "span_signature": [],
+ "text_sha256": "56201500eae3689cb69053ba3eb7439df814d6143f91dd40f98bff47221bf376"
+ },
+ {
+ "file": "procurement_document_blank_page_tables.pdf",
+ "page_index": 2,
+ "table_index": 1,
+ "bbox": [
+ 0.144,
+ 0.755,
+ 0.853,
+ 0.901
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 2,
+ "cols": 3,
+ "span_signature": [],
+ "text_sha256": "2c50430ff8e62a80a91343f0ef299f69cf9bd84b0831351a931f645b090989a6"
+ },
+ {
+ "file": "procurement_document_blank_page_tables.pdf",
+ "page_index": 3,
+ "table_index": 0,
+ "bbox": [
+ 0.143,
+ 0.091,
+ 0.852,
+ 0.219
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "rows": 1,
+ "cols": 3,
+ "span_signature": [],
+ "text_sha256": "a6ff60c437ff5a76b820349ae9c4439d78b883d4292a76c1915a5f2afb15dc63"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 1,
+ "table_index": 0,
+ "bbox": [
+ 0.047,
+ 0.346,
+ 0.951,
+ 0.482
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 3,
+ "cols": 8,
+ "span_signature": [
+ [
+ 1,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 1,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 1,
+ 2,
+ 2,
+ 1
+ ]
+ ],
+ "text_sha256": "9d44bbed1883eeec0c5c2d644fb57e46161f47b2e849fa3dd11d3862eca6f64a"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 1,
+ "table_index": 1,
+ "bbox": [
+ 0.05,
+ 0.658,
+ 0.952,
+ 0.689
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "rows": 1,
+ "cols": 10,
+ "span_signature": [],
+ "text_sha256": "85ebb40794f7aa7e77c782fd1ac20ef9c7a1819fb62a460c4a56d27c089bd455"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 2,
+ "table_index": 0,
+ "bbox": [
+ 0.047,
+ 0.15,
+ 0.952,
+ 0.678
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 12,
+ "cols": 13,
+ "span_signature": [
+ [
+ 1,
+ 0,
+ 11,
+ 1
+ ],
+ [
+ 1,
+ 1,
+ 11,
+ 1
+ ],
+ [
+ 1,
+ 2,
+ 11,
+ 1
+ ],
+ [
+ 1,
+ 3,
+ 3,
+ 1
+ ],
+ [
+ 1,
+ 4,
+ 3,
+ 1
+ ],
+ [
+ 1,
+ 12,
+ 3,
+ 1
+ ],
+ [
+ 4,
+ 3,
+ 6,
+ 1
+ ],
+ [
+ 4,
+ 4,
+ 6,
+ 1
+ ],
+ [
+ 4,
+ 12,
+ 6,
+ 1
+ ],
+ [
+ 10,
+ 3,
+ 2,
+ 1
+ ],
+ [
+ 10,
+ 4,
+ 2,
+ 1
+ ],
+ [
+ 10,
+ 12,
+ 2,
+ 1
+ ]
+ ],
+ "text_sha256": "ec07c9fadb35f5c3fdd63df1adaccd3346f3f6c27cc9067b0d41751645cc27fe"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 3,
+ "table_index": 0,
+ "bbox": [
+ 0.047,
+ 0.149,
+ 0.951,
+ 0.363
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 5,
+ "cols": 13,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 5,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 5,
+ 1
+ ],
+ [
+ 0,
+ 2,
+ 5,
+ 1
+ ],
+ [
+ 0,
+ 3,
+ 2,
+ 1
+ ],
+ [
+ 0,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
+ 3,
+ 1
+ ],
+ [
+ 2,
+ 3,
+ 3,
+ 1
+ ],
+ [
+ 2,
+ 4,
+ 3,
+ 1
+ ]
+ ],
+ "text_sha256": "36bbaa1f5e01cbebd709b54b23a18aa1d1075f0c3037cd495927df1d5f555dfc",
+ "target_reason": "canonical_track_alias"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 13,
+ "table_index": 0,
+ "bbox": [
+ 0.032,
+ 0.149,
+ 0.967,
+ 0.695
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "rows": 7,
+ "cols": 19,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 2,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 3,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 4,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 5,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 6,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 7,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 8,
+ 1,
+ 6
+ ],
+ [
+ 0,
+ 14,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 15,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 16,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 17,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 18,
+ 2,
+ 1
+ ],
+ [
+ 2,
+ 0,
+ 4,
+ 1
+ ],
+ [
+ 2,
+ 1,
+ 4,
+ 1
+ ],
+ [
+ 2,
+ 2,
+ 4,
+ 1
+ ],
+ [
+ 2,
+ 3,
+ 4,
+ 1
+ ],
+ [
+ 2,
+ 4,
+ 4,
+ 1
+ ]
+ ],
+ "text_sha256": "b816f259927cd8c8348a69fd8e344b014f1e672af195f269644122136145e5ce",
+ "target_reason": "canonical_track_alias"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 14,
+ "table_index": 0,
+ "bbox": [
+ 0.032,
+ 0.149,
+ 0.967,
+ 0.695
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "rows": 7,
+ "cols": 19,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 2,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 3,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 4,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 5,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 6,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 7,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 8,
+ 1,
+ 6
+ ],
+ [
+ 0,
+ 14,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 15,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 16,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 17,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 18,
+ 2,
+ 1
+ ],
+ [
+ 2,
+ 0,
+ 4,
+ 1
+ ],
+ [
+ 2,
+ 1,
+ 4,
+ 1
+ ],
+ [
+ 2,
+ 2,
+ 4,
+ 1
+ ],
+ [
+ 2,
+ 3,
+ 4,
+ 1
+ ],
+ [
+ 2,
+ 4,
+ 4,
+ 1
+ ]
+ ],
+ "text_sha256": "11733f9afbd79cd992af510aa155bdf9d38727465463e9ee3d462a52b417f00a",
+ "target_reason": "canonical_track_alias"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 15,
+ "table_index": 0,
+ "bbox": [
+ 0.032,
+ 0.149,
+ 0.967,
+ 0.694
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "rows": 6,
+ "cols": 19,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+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 2,
+ 1
+ ],
+ [
+ 0,
+ 18,
+ 2,
+ 1
+ ]
+ ],
+ "text_sha256": "0b53fb535c7056e1886d44842a0fa3f9f9b54d3c6b5cd32c65806b3bb8293896",
+ "target_reason": "canonical_track_alias"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 17,
+ "table_index": 0,
+ "bbox": [
+ 0.031,
+ 0.149,
+ 0.967,
+ 0.693
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "rows": 6,
+ "cols": 19,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 2,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 3,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 4,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 5,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 6,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 7,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 8,
+ 1,
+ 6
+ ],
+ [
+ 0,
+ 14,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 15,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 16,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 17,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 18,
+ 2,
+ 1
+ ]
+ ],
+ "text_sha256": "8fd8a101e53cf232ac4a24f505617b18c2d3c75239661322c6c3a1dfbfdce044",
+ "target_reason": "canonical_track_alias"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 18,
+ "table_index": 0,
+ "bbox": [
+ 0.031,
+ 0.149,
+ 0.967,
+ 0.693
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "rows": 6,
+ "cols": 19,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ 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+ ],
+ [
+ 0,
+ 18,
+ 2,
+ 1
+ ]
+ ],
+ "text_sha256": "0d5a51a80c1511330f104fb2ab52213ee68d93585ec1545630c4fe4e00864b39",
+ "target_reason": "canonical_track_alias"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 20,
+ "table_index": 0,
+ "bbox": [
+ 0.031,
+ 0.149,
+ 0.967,
+ 0.694
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "rows": 6,
+ "cols": 19,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 2,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 3,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 4,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 5,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 6,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 7,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 8,
+ 1,
+ 6
+ ],
+ [
+ 0,
+ 14,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 15,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 16,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 17,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 18,
+ 2,
+ 1
+ ]
+ ],
+ "text_sha256": "be15439fd1171187cd50829133251a3ebeb00350d7669517906a383b879bb752",
+ "target_reason": "canonical_track_alias"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 21,
+ "table_index": 0,
+ "bbox": [
+ 0.032,
+ 0.149,
+ 0.967,
+ 0.693
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "rows": 6,
+ "cols": 19,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 2,
+ 2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
+ 18,
+ 2,
+ 1
+ ]
+ ],
+ "text_sha256": "a58a6179db6b1c6bacae3fc5b338242259e9d1eee3a1e964e1b5d1f1dba360c3",
+ "target_reason": "canonical_track_alias"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 23,
+ "table_index": 0,
+ "bbox": [
+ 0.031,
+ 0.149,
+ 0.967,
+ 0.693
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "rows": 6,
+ "cols": 19,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 2,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 3,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 4,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 5,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 6,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 7,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 8,
+ 1,
+ 6
+ ],
+ [
+ 0,
+ 14,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 15,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 16,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 17,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 18,
+ 2,
+ 1
+ ]
+ ],
+ "text_sha256": "a6f0c74060b981c6ac39beeb8ac1b5907ade247694b1fbd50b12e98401f1f490",
+ "target_reason": "canonical_track_alias"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 24,
+ "table_index": 0,
+ "bbox": [
+ 0.031,
+ 0.149,
+ 0.967,
+ 0.694
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "rows": 6,
+ "cols": 19,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 2,
+ 2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,
+ 18,
+ 2,
+ 1
+ ]
+ ],
+ "text_sha256": "b5a6b192486bf9c4e9f2fdf6f9b5dc07039bd6a625cb984ba8a2fab84c79e09b",
+ "target_reason": "canonical_track_alias"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 26,
+ "table_index": 0,
+ "bbox": [
+ 0.031,
+ 0.149,
+ 0.967,
+ 0.693
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "rows": 6,
+ "cols": 19,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 2,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 3,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 4,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 5,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 6,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 7,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 8,
+ 1,
+ 6
+ ],
+ [
+ 0,
+ 14,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 15,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 16,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 17,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 18,
+ 2,
+ 1
+ ]
+ ],
+ "text_sha256": "7c9e5a1f6273156a6dd6f136f8ec0ec113c262bbe016bc03dd4674033d4f616f",
+ "target_reason": "canonical_track_alias"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 27,
+ "table_index": 0,
+ "bbox": [
+ 0.031,
+ 0.149,
+ 0.967,
+ 0.694
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "rows": 6,
+ "cols": 19,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 2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 0,
+ 18,
+ 2,
+ 1
+ ],
+ [
+ 2,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 2,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 2,
+ 2,
+ 2,
+ 1
+ ],
+ [
+ 2,
+ 3,
+ 2,
+ 1
+ ],
+ [
+ 2,
+ 4,
+ 2,
+ 1
+ ]
+ ],
+ "text_sha256": "3106f3317a87cba1a3683c6a91e3214658a7e7d2d3474317cf8fa73527515579",
+ "target_reason": "canonical_track_alias"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 30,
+ "table_index": 0,
+ "bbox": [
+ 0.032,
+ 0.174,
+ 0.968,
+ 0.679
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 3,
+ "cols": 20,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 2,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 3,
+ 1,
+ 9
+ ],
+ [
+ 0,
+ 12,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 13,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 14,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 15,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 16,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 17,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 18,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 19,
+ 2,
+ 1
+ ]
+ ],
+ "text_sha256": "386799ed2a97572a7eba7f0e743c23e091acecc80c113bf9ee5dbb1856e2bcc4"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 31,
+ "table_index": 0,
+ "bbox": [
+ 0.032,
+ 0.149,
+ 0.968,
+ 0.693
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 4,
+ "cols": 20,
+ "span_signature": [
+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 2,
+ 0,
+ 2,
+ 1
+ ]
+ ],
+ "text_sha256": "69a6452bf68db05ef551aa99cc507380c94ddd8bc59c4ca7397fa9be8dc6abc0"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 33,
+ "table_index": 0,
+ "bbox": [
+ 0.031,
+ 0.149,
+ 0.968,
+ 0.523
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 3,
+ "cols": 20,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 2,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 3,
+ 1,
+ 9
+ ],
+ [
+ 0,
+ 12,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 13,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 14,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 15,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 16,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 17,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 18,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 19,
+ 2,
+ 1
+ ]
+ ],
+ "text_sha256": "d1fa7bda69e183d7576a8ee3783fd4a5fdc0e8fe1cc32b4c914f491c58917626"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 35,
+ "table_index": 0,
+ "bbox": [
+ 0.077,
+ 0.299,
+ 0.921,
+ 0.683
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 5,
+ "cols": 10,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 2,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 3,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 4,
+ 1,
+ 2
+ ],
+ [
+ 0,
+ 6,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 7,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 8,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 9,
+ 2,
+ 1
+ ]
+ ],
+ "text_sha256": "26f3baff18adda46c5e72f613be50eaae6595828e04ff1d3819e8caa7be2b9f5"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 36,
+ "table_index": 0,
+ "bbox": [
+ 0.076,
+ 0.149,
+ 0.921,
+ 0.561
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 7,
+ "cols": 10,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 2,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 3,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 4,
+ 1,
+ 2
+ ],
+ [
+ 0,
+ 6,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 7,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 8,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 9,
+ 2,
+ 1
+ ]
+ ],
+ "text_sha256": "69be1a0181d8a81f4da0a7395f369d1e6db51464846657eaa1548d737a4dd8e2"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 37,
+ "table_index": 0,
+ "bbox": [
+ 0.077,
+ 0.174,
+ 0.922,
+ 0.677
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 5,
+ "cols": 10,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 2,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 3,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 4,
+ 1,
+ 3
+ ],
+ [
+ 0,
+ 7,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 8,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 9,
+ 2,
+ 1
+ ]
+ ],
+ "text_sha256": "4b2b93d8ef76e633407428348b65bfe55ea7e587b7a1368c1896c2202a13465e"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 38,
+ "table_index": 0,
+ "bbox": [
+ 0.076,
+ 0.15,
+ 0.922,
+ 0.679
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 6,
+ "cols": 10,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 2,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 3,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 4,
+ 1,
+ 3
+ ],
+ [
+ 0,
+ 7,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 8,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 9,
+ 2,
+ 1
+ ]
+ ],
+ "text_sha256": "70264f91860ea5c8c1fa445083c2b24cefbc40772723d15483e224ec4738c893"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 39,
+ "table_index": 0,
+ "bbox": [
+ 0.076,
+ 0.15,
+ 0.922,
+ 0.679
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 6,
+ "cols": 10,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 2,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 3,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 4,
+ 1,
+ 3
+ ],
+ [
+ 0,
+ 7,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 8,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 9,
+ 2,
+ 1
+ ]
+ ],
+ "text_sha256": "c629bf2983199a84c906318d9a6692d74f292b4c2ab53503bf4f1051b44ca6d0"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 40,
+ "table_index": 0,
+ "bbox": [
+ 0.076,
+ 0.149,
+ 0.921,
+ 0.548
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 6,
+ "cols": 10,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 2,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 3,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 4,
+ 1,
+ 3
+ ],
+ [
+ 0,
+ 7,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 8,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 9,
+ 2,
+ 1
+ ]
+ ],
+ "text_sha256": "3d4b1caf73d4065fa3a1c122694f0b3810e7f73b08fa09a54afa52e48f442417"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 42,
+ "table_index": 0,
+ "bbox": [
+ 0.068,
+ 0.236,
+ 0.93,
+ 0.689
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "rows": 8,
+ "cols": 13,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 2,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 3,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 4,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 5,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 6,
+ 1,
+ 5
+ ],
+ [
+ 0,
+ 11,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 12,
+ 2,
+ 1
+ ],
+ [
+ 2,
+ 0,
+ 1,
+ 13
+ ]
+ ],
+ "text_sha256": "66191f7b01a8bd61d6840cc07827c1ae66cc149397051c23d96297b751a15dcf",
+ "target_reason": "canonical_track_alias"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 43,
+ "table_index": 0,
+ "bbox": [
+ 0.068,
+ 0.149,
+ 0.93,
+ 0.683
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 9,
+ "cols": 14,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 2,
+ 2,
+ 2
+ ],
+ [
+ 0,
+ 4,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 5,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 6,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 7,
+ 1,
+ 5
+ ],
+ [
+ 0,
+ 12,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 13,
+ 2,
+ 1
+ ],
+ [
+ 2,
+ 2,
+ 1,
+ 2
+ ],
+ [
+ 3,
+ 2,
+ 1,
+ 2
+ ],
+ [
+ 4,
+ 2,
+ 1,
+ 2
+ ],
+ [
+ 5,
+ 2,
+ 1,
+ 2
+ ],
+ [
+ 6,
+ 0,
+ 3,
+ 3
+ ],
+ [
+ 6,
+ 3,
+ 1,
+ 4
+ ],
+ [
+ 7,
+ 3,
+ 1,
+ 4
+ ],
+ [
+ 8,
+ 3,
+ 1,
+ 4
+ ]
+ ],
+ "text_sha256": "ebb899ba3f5eb926c83dda979f3c49460e19eacc5661698b7cd8a2882bb5d0cc"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 44,
+ "table_index": 0,
+ "bbox": [
+ 0.068,
+ 0.149,
+ 0.93,
+ 0.683
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "rows": 9,
+ "cols": 14,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ ],
+ [
+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+ ],
+ [
+ 3,
+ 0,
+ 4,
+ 3
+ ],
+ [
+ 3,
+ 3,
+ 1,
+ 4
+ ],
+ [
+ 4,
+ 3,
+ 1,
+ 4
+ ],
+ [
+ 5,
+ 3,
+ 1,
+ 4
+ ],
+ [
+ 6,
+ 3,
+ 1,
+ 4
+ ],
+ [
+ 7,
+ 0,
+ 1,
+ 14
+ ],
+ [
+ 8,
+ 0,
+ 4,
+ 3
+ ],
+ [
+ 8,
+ 3,
+ 1,
+ 4
+ ],
+ [
+ 9,
+ 3,
+ 1,
+ 4
+ ],
+ [
+ 10,
+ 3,
+ 1,
+ 4
+ ],
+ [
+ 11,
+ 3,
+ 1,
+ 4
+ ]
+ ],
+ "text_sha256": "814854eed2f4961152ef1b17e2422d3cc92250abe8ffdcc8f496cc18c6db2660"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 46,
+ "table_index": 0,
+ "bbox": [
+ 0.069,
+ 0.149,
+ 0.929,
+ 0.585
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "target_reason": "strong_single_column_line_grid",
+ "rows": 5,
+ "cols": 1,
+ "span_signature": [],
+ "text_sha256": "9a45006a8964a521e15842c4cf9b32e5ed7e22f2c9e03a3d50dc1f44572c624b"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 48,
+ "table_index": 0,
+ "bbox": [
+ 0.046,
+ 0.236,
+ 0.953,
+ 0.677
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 12,
+ "cols": 14,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 2,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 3,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 4,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 5,
+ 1,
+ 2
+ ],
+ [
+ 0,
+ 7,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 8,
+ 1,
+ 5
+ ],
+ [
+ 0,
+ 13,
+ 2,
+ 1
+ ]
+ ],
+ "text_sha256": "dc7fa47d9a797d698f0c22c9662e5115cdc7fc54b32c6cd4d62cfbc1d6b646f1"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 49,
+ "table_index": 0,
+ "bbox": [
+ 0.046,
+ 0.149,
+ 0.953,
+ 0.689
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 20,
+ "cols": 14,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 2,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 3,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 4,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 5,
+ 1,
+ 2
+ ],
+ [
+ 0,
+ 7,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 8,
+ 1,
+ 5
+ ],
+ [
+ 0,
+ 13,
+ 2,
+ 1
+ ]
+ ],
+ "text_sha256": "6ce730aa700d6d95ec6769e3155e79bad67166f2c2bbb598bba291555defb193"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 50,
+ "table_index": 0,
+ "bbox": [
+ 0.046,
+ 0.149,
+ 0.952,
+ 0.531
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 13,
+ "cols": 14,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 2,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 3,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 4,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 5,
+ 1,
+ 2
+ ],
+ [
+ 0,
+ 7,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 8,
+ 1,
+ 5
+ ],
+ [
+ 0,
+ 13,
+ 2,
+ 1
+ ],
+ [
+ 8,
+ 0,
+ 1,
+ 14
+ ],
+ [
+ 9,
+ 0,
+ 4,
+ 3
+ ],
+ [
+ 9,
+ 3,
+ 1,
+ 5
+ ],
+ [
+ 10,
+ 3,
+ 1,
+ 5
+ ],
+ [
+ 11,
+ 3,
+ 1,
+ 5
+ ],
+ [
+ 12,
+ 3,
+ 1,
+ 5
+ ]
+ ],
+ "text_sha256": "1f273bf0778dc26d6a5331b6f3ff1d876dde83c476d1c9424b552650fd1b3897"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 51,
+ "table_index": 0,
+ "bbox": [
+ 0.078,
+ 0.279,
+ 0.921,
+ 0.478
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 5,
+ "cols": 7,
+ "span_signature": [],
+ "text_sha256": "dede35df351b7b9948a93309f53cca60fd1a2063ff9973d4d2d9555a1acfba3a"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 53,
+ "table_index": 0,
+ "bbox": [
+ 0.09,
+ 0.299,
+ 0.909,
+ 0.468
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "target_reason": "physical_blank_row",
+ "rows": 3,
+ "cols": 13,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 2,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 3,
+ 1,
+ 2
+ ],
+ [
+ 0,
+ 5,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 6,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 7,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 8,
+ 1,
+ 2
+ ],
+ [
+ 0,
+ 10,
+ 1,
+ 2
+ ],
+ [
+ 0,
+ 12,
+ 2,
+ 1
+ ],
+ [
+ 2,
+ 0,
+ 1,
+ 13
+ ]
+ ],
+ "text_sha256": "abc97a9378840af6fb20fd2e9c5ed38e575f45ed017c253600be37cdbdbe9d84"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 53,
+ "table_index": 1,
+ "bbox": [
+ 0.08,
+ 0.545,
+ 0.918,
+ 0.633
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "target_reason": "physical_blank_row",
+ "rows": 3,
+ "cols": 7,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 2,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 3,
+ 1,
+ 3
+ ],
+ [
+ 0,
+ 6,
+ 2,
+ 1
+ ],
+ [
+ 2,
+ 0,
+ 1,
+ 7
+ ]
+ ],
+ "text_sha256": "529d475596688e733e86c99402a47610179c2f168c2ba2fc1f4fda4980123be5"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 54,
+ "table_index": 0,
+ "bbox": [
+ 0.09,
+ 0.223,
+ 0.909,
+ 0.392
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "target_reason": "physical_blank_row",
+ "rows": 3,
+ "cols": 13,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 2,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 3,
+ 1,
+ 2
+ ],
+ [
+ 0,
+ 5,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 6,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 7,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 8,
+ 1,
+ 2
+ ],
+ [
+ 0,
+ 10,
+ 1,
+ 2
+ ],
+ [
+ 0,
+ 12,
+ 2,
+ 1
+ ],
+ [
+ 2,
+ 0,
+ 1,
+ 13
+ ]
+ ],
+ "text_sha256": "abc97a9378840af6fb20fd2e9c5ed38e575f45ed017c253600be37cdbdbe9d84"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 55,
+ "table_index": 0,
+ "bbox": [
+ 0.089,
+ 0.264,
+ 0.909,
+ 0.427
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "target_reason": "physical_blank_row",
+ "rows": 3,
+ "cols": 12,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 2,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 3,
+ 1,
+ 2
+ ],
+ [
+ 0,
+ 5,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 6,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 7,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 8,
+ 1,
+ 4
+ ],
+ [
+ 2,
+ 0,
+ 1,
+ 12
+ ]
+ ],
+ "text_sha256": "92c6304b4ec5b6eea640d14aed5ab12bee2580517e5ce4710490aaa52db072be"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 56,
+ "table_index": 0,
+ "bbox": [
+ 0.091,
+ 0.216,
+ 0.907,
+ 0.326
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "target_reason": "physical_blank_row",
+ "rows": 3,
+ "cols": 10,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 2,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 3,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 4,
+ 1,
+ 2
+ ],
+ [
+ 0,
+ 6,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 7,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 8,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 9,
+ 2,
+ 1
+ ],
+ [
+ 2,
+ 0,
+ 1,
+ 10
+ ]
+ ],
+ "text_sha256": "d8d6e0d1394542f6537e013fe923897065c3d59b9e8ccafcd979fcdc0d737e53"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 57,
+ "table_index": 0,
+ "bbox": [
+ 0.077,
+ 0.236,
+ 0.922,
+ 0.578
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "target_reason": "physical_blank_row",
+ "rows": 13,
+ "cols": 11,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 2,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 3,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 4,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 5,
+ 1,
+ 5
+ ],
+ [
+ 0,
+ 10,
+ 2,
+ 1
+ ],
+ [
+ 2,
+ 0,
+ 1,
+ 11
+ ],
+ [
+ 3,
+ 0,
+ 1,
+ 11
+ ],
+ [
+ 4,
+ 0,
+ 2,
+ 3
+ ],
+ [
+ 4,
+ 3,
+ 1,
+ 2
+ ],
+ [
+ 5,
+ 3,
+ 1,
+ 2
+ ],
+ [
+ 6,
+ 0,
+ 1,
+ 11
+ ],
+ [
+ 7,
+ 0,
+ 1,
+ 11
+ ],
+ [
+ 8,
+ 0,
+ 2,
+ 3
+ ],
+ [
+ 8,
+ 3,
+ 1,
+ 2
+ ],
+ [
+ 9,
+ 3,
+ 1,
+ 2
+ ],
+ [
+ 10,
+ 0,
+ 1,
+ 11
+ ],
+ [
+ 11,
+ 0,
+ 2,
+ 3
+ ],
+ [
+ 11,
+ 3,
+ 1,
+ 2
+ ],
+ [
+ 12,
+ 3,
+ 1,
+ 2
+ ]
+ ],
+ "text_sha256": "d600150e6ce968d53bff9ec6692f831e0a977c65fb666d1bf6dbb60e813b65b7"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 60,
+ "table_index": 0,
+ "bbox": [
+ 0.081,
+ 0.279,
+ 0.917,
+ 0.687
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 4,
+ "cols": 10,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 1,
+ 10
+ ]
+ ],
+ "text_sha256": "bf969fef10bf457290c223e2a3692b5e2dd0e9c4811e122e2180e1c7ed649e02"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 61,
+ "table_index": 0,
+ "bbox": [
+ 0.081,
+ 0.149,
+ 0.917,
+ 0.338
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 3,
+ "cols": 10,
+ "span_signature": [],
+ "text_sha256": "db7d286c0a705906d7b51e11454b5f9a86624fd5d0fe00077cf3c79c59f14961"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 61,
+ "table_index": 1,
+ "bbox": [
+ 0.081,
+ 0.412,
+ 0.917,
+ 0.68
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 8,
+ "cols": 14,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 1,
+ 8
+ ],
+ [
+ 0,
+ 8,
+ 1,
+ 6
+ ],
+ [
+ 1,
+ 0,
+ 1,
+ 14
+ ],
+ [
+ 2,
+ 0,
+ 1,
+ 3
+ ],
+ [
+ 2,
+ 3,
+ 1,
+ 5
+ ],
+ [
+ 2,
+ 8,
+ 1,
+ 3
+ ],
+ [
+ 2,
+ 11,
+ 1,
+ 3
+ ],
+ [
+ 3,
+ 0,
+ 1,
+ 3
+ ],
+ [
+ 3,
+ 3,
+ 1,
+ 5
+ ],
+ [
+ 3,
+ 8,
+ 1,
+ 3
+ ],
+ [
+ 3,
+ 11,
+ 1,
+ 3
+ ],
+ [
+ 4,
+ 0,
+ 1,
+ 3
+ ],
+ [
+ 4,
+ 3,
+ 1,
+ 5
+ ],
+ [
+ 4,
+ 8,
+ 1,
+ 3
+ ],
+ [
+ 4,
+ 11,
+ 1,
+ 3
+ ],
+ [
+ 5,
+ 0,
+ 1,
+ 3
+ ],
+ [
+ 5,
+ 3,
+ 1,
+ 2
+ ],
+ [
+ 5,
+ 5,
+ 1,
+ 2
+ ],
+ [
+ 5,
+ 8,
+ 1,
+ 3
+ ],
+ [
+ 5,
+ 11,
+ 1,
+ 3
+ ],
+ [
+ 6,
+ 0,
+ 1,
+ 14
+ ],
+ [
+ 7,
+ 2,
+ 1,
+ 2
+ ],
+ [
+ 7,
+ 4,
+ 1,
+ 2
+ ],
+ [
+ 7,
+ 6,
+ 1,
+ 2
+ ],
+ [
+ 7,
+ 10,
+ 1,
+ 2
+ ]
+ ],
+ "text_sha256": "822dea9bb19cd89b08f3c9f8f03363debbe1247bff042639386bacc3c6e91b45"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 62,
+ "table_index": 0,
+ "bbox": [
+ 0.081,
+ 0.149,
+ 0.917,
+ 0.397
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "target_reason": "outer_edge_duplicate_track",
+ "rows": 4,
+ "cols": 10,
+ "span_signature": [
+ [
+ 1,
+ 0,
+ 1,
+ 10
+ ],
+ [
+ 2,
+ 0,
+ 1,
+ 10
+ ],
+ [
+ 3,
+ 0,
+ 1,
+ 10
+ ]
+ ],
+ "text_sha256": "2f7304ac1be915f56b615e8b28f27fb7cfecabe2da474dc7e3140e9340c649a6"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 62,
+ "table_index": 1,
+ "bbox": [
+ 0.082,
+ 0.435,
+ 0.917,
+ 0.672
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 7,
+ "cols": 6,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 1,
+ 4
+ ],
+ [
+ 0,
+ 4,
+ 1,
+ 2
+ ],
+ [
+ 1,
+ 0,
+ 1,
+ 6
+ ],
+ [
+ 2,
+ 1,
+ 1,
+ 3
+ ],
+ [
+ 3,
+ 1,
+ 1,
+ 3
+ ],
+ [
+ 4,
+ 1,
+ 1,
+ 3
+ ],
+ [
+ 6,
+ 0,
+ 1,
+ 6
+ ]
+ ],
+ "text_sha256": "d9b759e238855d66ac6e99a5ab296428c37eb307d86a209956f0fe809f3906be"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 63,
+ "table_index": 0,
+ "bbox": [
+ 0.081,
+ 0.149,
+ 0.917,
+ 0.401
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "target_reason": "outer_edge_duplicate_track",
+ "rows": 5,
+ "cols": 10,
+ "span_signature": [
+ [
+ 2,
+ 0,
+ 1,
+ 10
+ ],
+ [
+ 3,
+ 0,
+ 1,
+ 10
+ ],
+ [
+ 4,
+ 0,
+ 1,
+ 10
+ ]
+ ],
+ "text_sha256": "8cfdf6818cb161bbe5cfe7bddf7fdbf219e63a23c815d0bc488005c144760611"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 63,
+ "table_index": 1,
+ "bbox": [
+ 0.085,
+ 0.542,
+ 0.914,
+ 0.674
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 4,
+ "cols": 4,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 4
+ ]
+ ],
+ "text_sha256": "d03cbdbbbb77e5d8dc54829f1734fa03999fb37c156187bc307d8c0623d0a714"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 64,
+ "table_index": 0,
+ "bbox": [
+ 0.084,
+ 0.15,
+ 0.914,
+ 0.661
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 12,
+ "cols": 6,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 2
+ ],
+ [
+ 0,
+ 2,
+ 1,
+ 4
+ ],
+ [
+ 1,
+ 2,
+ 1,
+ 2
+ ],
+ [
+ 1,
+ 4,
+ 1,
+ 2
+ ],
+ [
+ 2,
+ 0,
+ 1,
+ 2
+ ],
+ [
+ 2,
+ 2,
+ 1,
+ 2
+ ],
+ [
+ 2,
+ 4,
+ 1,
+ 2
+ ],
+ [
+ 3,
+ 0,
+ 1,
+ 6
+ ],
+ [
+ 4,
+ 0,
+ 3,
+ 1
+ ],
+ [
+ 4,
+ 1,
+ 3,
+ 1
+ ],
+ [
+ 4,
+ 2,
+ 1,
+ 4
+ ],
+ [
+ 5,
+ 3,
+ 1,
+ 3
+ ],
+ [
+ 11,
+ 4,
+ 1,
+ 2
+ ]
+ ],
+ "text_sha256": "aeab2147c34d8cc05b75b1d09adbb8340a759eafc92a08033a2cd55a4873b7d2"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 65,
+ "table_index": 0,
+ "bbox": [
+ 0.083,
+ 0.15,
+ 0.914,
+ 0.58
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 6,
+ "cols": 5,
+ "span_signature": [
+ [
+ 4,
+ 0,
+ 1,
+ 5
+ ],
+ [
+ 5,
+ 0,
+ 1,
+ 5
+ ]
+ ],
+ "text_sha256": "b32a8464e7faf5248d7ca378266f12df74bd887f9796b15df76847b74f1b7101"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 66,
+ "table_index": 0,
+ "bbox": [
+ 0.056,
+ 0.243,
+ 0.942,
+ 0.686
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 3,
+ "cols": 15,
+ "span_signature": [],
+ "text_sha256": "8a4e9961aa5a5435140c4f2739062038693204c0bb455a3f73653a226688e4bf"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 67,
+ "table_index": 0,
+ "bbox": [
+ 0.056,
+ 0.15,
+ 0.943,
+ 0.682
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 3,
+ "cols": 15,
+ "span_signature": [],
+ "text_sha256": "dd09406289c01d6df0c8e98a59333df322ba49c87bcb2c5bbebcecfc11313d50"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 68,
+ "table_index": 0,
+ "bbox": [
+ 0.056,
+ 0.149,
+ 0.942,
+ 0.683
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 4,
+ "cols": 15,
+ "span_signature": [],
+ "text_sha256": "4c886dafbc47f31e94ad48268f5ac10a1ac583a2371c311cce45b0a08582ae05"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 69,
+ "table_index": 0,
+ "bbox": [
+ 0.056,
+ 0.149,
+ 0.943,
+ 0.682
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 3,
+ "cols": 15,
+ "span_signature": [],
+ "text_sha256": "947e33095354f178a4a617202c37eeec86622c45fe7c809cd0980277f6659c25"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 70,
+ "table_index": 0,
+ "bbox": [
+ 0.056,
+ 0.15,
+ 0.942,
+ 0.683
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 3,
+ "cols": 15,
+ "span_signature": [],
+ "text_sha256": "1b4335d34b5b8c6b6ffbd4abe9cee1671e6477436f6373d02a136cff0b586530"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 71,
+ "table_index": 0,
+ "bbox": [
+ 0.056,
+ 0.149,
+ 0.942,
+ 0.684
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 4,
+ "cols": 15,
+ "span_signature": [],
+ "text_sha256": "0f82f933f03e9c97e8d130f3535487b55a5151c3e2ceecb531f1fa36870ae28e"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 72,
+ "table_index": 0,
+ "bbox": [
+ 0.056,
+ 0.15,
+ 0.942,
+ 0.682
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 3,
+ "cols": 15,
+ "span_signature": [],
+ "text_sha256": "950a2375cc33ec0dc035e36e95f27323d10eafdb4d52170b536670ebc9a6c02a"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 73,
+ "table_index": 0,
+ "bbox": [
+ 0.056,
+ 0.15,
+ 0.942,
+ 0.683
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 3,
+ "cols": 15,
+ "span_signature": [],
+ "text_sha256": "90a5186230e7044fc036d767a490f434d0f111ce1e9b32f7b91a20da63d6cb07"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 74,
+ "table_index": 0,
+ "bbox": [
+ 0.055,
+ 0.149,
+ 0.942,
+ 0.569
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 4,
+ "cols": 15,
+ "span_signature": [],
+ "text_sha256": "5a1820e2bc2758c78f996acee7601d16f1df0b503fe43aac0d218eea5dadf6f5"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 77,
+ "table_index": 0,
+ "bbox": [
+ 0.14,
+ 0.146,
+ 0.857,
+ 0.785
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 6,
+ "cols": 6,
+ "span_signature": [],
+ "text_sha256": "d7a93bbf6282ec895aeb7187f1b7ddc89adfccb67fb2f0f37e5642a81524f320"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 78,
+ "table_index": 0,
+ "bbox": [
+ 0.141,
+ 0.086,
+ 0.857,
+ 0.783
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 5,
+ "cols": 6,
+ "span_signature": [],
+ "text_sha256": "f751d0f566056aa4e8b7bad15e215a5966ddc9cf996de249cc18ec69f86a0aec"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 79,
+ "table_index": 0,
+ "bbox": [
+ 0.141,
+ 0.085,
+ 0.857,
+ 0.607
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 3,
+ "cols": 6,
+ "span_signature": [],
+ "text_sha256": "7898488bc258d80a2cba4111bc398aadaf6a5bbb02c7f28e5eddff5c09b47342"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 80,
+ "table_index": 0,
+ "bbox": [
+ 0.047,
+ 0.313,
+ 0.951,
+ 0.418
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 2,
+ "cols": 7,
+ "span_signature": [],
+ "text_sha256": "09cae9d74ed2ba7375634ae3e4cd3ff33151b2a292b2351d38c747fee58b8261"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 80,
+ "table_index": 1,
+ "bbox": [
+ 0.048,
+ 0.492,
+ 0.951,
+ 0.584
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 2,
+ "cols": 6,
+ "span_signature": [
+ [
+ 1,
+ 0,
+ 1,
+ 6
+ ]
+ ],
+ "text_sha256": "41b45c1961218c75b05f99045e659dd9f6dfdc59f6e94a3d6c6a7684ce66a6ef"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 81,
+ "table_index": 0,
+ "bbox": [
+ 0.047,
+ 0.15,
+ 0.952,
+ 0.242
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 2,
+ "cols": 6,
+ "span_signature": [
+ [
+ 1,
+ 0,
+ 1,
+ 6
+ ]
+ ],
+ "text_sha256": "a1ac37c84bb7b8913fa19c461706828805cd434bb59c9f0aea8e503e30d521ff"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 81,
+ "table_index": 1,
+ "bbox": [
+ 0.047,
+ 0.316,
+ 0.951,
+ 0.513
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 2,
+ "cols": 6,
+ "span_signature": [],
+ "text_sha256": "afc9d366a18c2ea698366a986f6a0e7edc916e0868030cf17241d7b736fbbc85"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 81,
+ "table_index": 2,
+ "bbox": [
+ 0.047,
+ 0.54,
+ 0.952,
+ 0.658
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 2,
+ "cols": 5,
+ "span_signature": [],
+ "text_sha256": "3f5f81a4031362e8d92dc9f5f6e78e1ef3842917e0563c9cfead89e038728d84"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 82,
+ "table_index": 0,
+ "bbox": [
+ 0.047,
+ 0.197,
+ 0.951,
+ 0.29
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 2,
+ "cols": 5,
+ "span_signature": [
+ [
+ 1,
+ 0,
+ 1,
+ 5
+ ]
+ ],
+ "text_sha256": "7d02fde92db7ffe3223491df45c34a88eb945d5118544f662d715a21e4de3bef"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 82,
+ "table_index": 1,
+ "bbox": [
+ 0.047,
+ 0.316,
+ 0.952,
+ 0.409
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 2,
+ "cols": 5,
+ "span_signature": [
+ [
+ 1,
+ 0,
+ 1,
+ 5
+ ]
+ ],
+ "text_sha256": "194763f985119aadf8aacba0a50a6c2a1e7fb8e5b899c5526ab3ba48aed4ae2c"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 82,
+ "table_index": 2,
+ "bbox": [
+ 0.048,
+ 0.482,
+ 0.951,
+ 0.574
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 2,
+ "cols": 5,
+ "span_signature": [
+ [
+ 1,
+ 0,
+ 1,
+ 5
+ ]
+ ],
+ "text_sha256": "7d60b1272dc37d43093a756350b38d3442bfe10d2336a6817f4c7bc2299bc59c"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 83,
+ "table_index": 0,
+ "bbox": [
+ 0.051,
+ 0.151,
+ 0.947,
+ 0.226
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 2,
+ "cols": 3,
+ "span_signature": [],
+ "text_sha256": "63877a6bc50f9424270d22e6397d432726c5ec0484f7e2d26e8cdb09dd55e943"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 84,
+ "table_index": 0,
+ "bbox": [
+ 0.083,
+ 0.15,
+ 0.915,
+ 0.232
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 2,
+ "cols": 6,
+ "span_signature": [
+ [
+ 1,
+ 0,
+ 1,
+ 6
+ ]
+ ],
+ "text_sha256": "d8e47a14def4de0ccd469f94f5a12a1669518bc77011639e2465631b8daa1a6d"
+ },
+ {
+ "file": "procurement_contract_tables.pdf",
+ "page_index": 0,
+ "table_index": 0,
+ "bbox": [
+ 0.139,
+ 0.489,
+ 0.859,
+ 0.569
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "rows": 2,
+ "cols": 2,
+ "span_signature": [],
+ "text_sha256": "d43223bb1a67a3c0a843fe927e3d948eec05d03de577bd8b0e15fe6f99512fb9"
+ },
+ {
+ "file": "procurement_contract_tables.pdf",
+ "page_index": 0,
+ "table_index": 1,
+ "bbox": [
+ 0.14,
+ 0.828,
+ 0.859,
+ 0.898
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 3,
+ "cols": 3,
+ "span_signature": [
+ [
+ 1,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 1,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 1,
+ 2,
+ 2,
+ 1
+ ]
+ ],
+ "text_sha256": "832106596b6066321211c9862a508270740978bb39d994c0d33d2aaa5564e45b"
+ },
+ {
+ "file": "procurement_contract_tables.pdf",
+ "page_index": 1,
+ "table_index": 0,
+ "bbox": [
+ 0.14,
+ 0.083,
+ 0.859,
+ 0.401
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 5,
+ "cols": 4,
+ "span_signature": [
+ [
+ 0,
+ 1,
+ 1,
+ 2
+ ],
+ [
+ 1,
+ 0,
+ 4,
+ 1
+ ],
+ [
+ 2,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 2,
+ 2,
+ 2,
+ 1
+ ],
+ [
+ 2,
+ 3,
+ 2,
+ 1
+ ]
+ ],
+ "text_sha256": "e3c47adee3fd3bf7db7d317b1bcfcca2793e5f4ca9c479e9a93e97f03d530230"
+ },
+ {
+ "file": "procurement_contract_tables.pdf",
+ "page_index": 1,
+ "table_index": 1,
+ "bbox": [
+ 0.137,
+ 0.669,
+ 0.857,
+ 0.806
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 4,
+ "cols": 2,
+ "span_signature": [],
+ "text_sha256": "6060a2f4d6a27746f206f1f432b931d8fee5f99eaa4af146bdd788e9f217c47d"
+ },
+ {
+ "file": "annual_report_research_projects_table.pdf",
+ "page_index": 0,
+ "table_index": 0,
+ "bbox": [
+ 0.083,
+ 0.139,
+ 0.898,
+ 0.91
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 6,
+ "cols": 5,
+ "span_signature": [],
+ "text_sha256": "c9a0a360b9163e73a1233514f2ad4c29fd1d9971c6cf33364ff1601db16f060b"
+ },
+ {
+ "file": "annual_report_research_projects_table.pdf",
+ "page_index": 1,
+ "table_index": 0,
+ "bbox": [
+ 0.084,
+ 0.083,
+ 0.897,
+ 0.281
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "rows": 1,
+ "cols": 5,
+ "span_signature": [],
+ "text_sha256": "2ef9fca3d29d3759a310c5a30916bb2995ac66b1b502e60238dd2e584a1830db"
+ },
+ {
+ "file": "annual_report_research_projects_table.pdf",
+ "page_index": 1,
+ "table_index": 1,
+ "bbox": [
+ 0.084,
+ 0.305,
+ 0.897,
+ 0.481
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 9,
+ "cols": 4,
+ "span_signature": [
+ [
+ 3,
+ 0,
+ 1,
+ 4
+ ],
+ [
+ 6,
+ 0,
+ 1,
+ 4
+ ]
+ ],
+ "text_sha256": "a2df13db67d4ae47aaf6b5e8035cd3d39a1c4f506ba3aa6ea2b6e9c0023549e8"
+ },
+ {
+ "file": "annual_report_research_projects_table.pdf",
+ "page_index": 1,
+ "table_index": 2,
+ "bbox": [
+ 0.084,
+ 0.505,
+ 0.897,
+ 0.631
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 5,
+ "cols": 4,
+ "span_signature": [],
+ "text_sha256": "547b1709643781f5b78e628ae41f9f482c92219b11badc57dccdd01291485e63"
+ },
+ {
+ "file": "annual_report_research_projects_table.pdf",
+ "page_index": 1,
+ "table_index": 3,
+ "bbox": [
+ 0.084,
+ 0.819,
+ 0.897,
+ 0.899
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 4,
+ "cols": 4,
+ "span_signature": [],
+ "text_sha256": "b0b7de04153947e0bcf15380d261f72de78a9ec68f0cbb2f775423f571573bf5"
+ },
+ {
+ "file": "annual_report_fundraising_projects_table.pdf",
+ "page_index": 0,
+ "table_index": 0,
+ "bbox": [
+ 0.083,
+ 0.085,
+ 0.897,
+ 0.91
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 14,
+ "cols": 11,
+ "span_signature": [
+ [
+ 1,
+ 0,
+ 1,
+ 11
+ ],
+ [
+ 10,
+ 0,
+ 1,
+ 11
+ ],
+ [
+ 13,
+ 1,
+ 1,
+ 10
+ ]
+ ],
+ "text_sha256": "7092c61dcc649d55840b9bf272d6a6b3695404cf6abd4de6c5747b6012cd9821"
+ },
+ {
+ "file": "annual_report_fundraising_projects_table.pdf",
+ "page_index": 1,
+ "table_index": 0,
+ "bbox": [
+ 0.083,
+ 0.083,
+ 0.897,
+ 0.898
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 12,
+ "cols": 2,
+ "span_signature": [
+ [
+ 3,
+ 0,
+ 3,
+ 1
+ ],
+ [
+ 6,
+ 0,
+ 3,
+ 1
+ ],
+ [
+ 9,
+ 0,
+ 2,
+ 1
+ ]
+ ],
+ "text_sha256": "79d3bee25a495158c12e63120a0f38c66d4f70f07168de58f3b3ffd5026bda16"
+ },
+ {
+ "file": "annual_report_management_roles_table.pdf",
+ "page_index": 0,
+ "table_index": 0,
+ "bbox": [
+ 0.084,
+ 0.575,
+ 0.897,
+ 0.696
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 3,
+ "cols": 6,
+ "span_signature": [],
+ "text_sha256": "a2257a9f4b6c73d96d48b7d5f5ea153282c144425210519d4b05ab474ec36175"
+ },
+ {
+ "file": "annual_report_management_roles_table.pdf",
+ "page_index": 0,
+ "table_index": 1,
+ "bbox": [
+ 0.084,
+ 0.741,
+ 0.897,
+ 0.907
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 6,
+ "cols": 6,
+ "span_signature": [],
+ "text_sha256": "b9bf1096012d98434c43318fc080b8ab24c64232718a6d82afc67ebcc5481338"
+ },
+ {
+ "file": "annual_report_management_roles_table.pdf",
+ "page_index": 1,
+ "table_index": 0,
+ "bbox": [
+ 0.083,
+ 0.084,
+ 0.898,
+ 0.881
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 24,
+ "cols": 6,
+ "span_signature": [
+ [
+ 23,
+ 1,
+ 1,
+ 5
+ ]
+ ],
+ "text_sha256": "1be9a3fe8f7d475326a69238903ade16209bca2ada1bd744f3645c37eddb8950"
+ },
+ {
+ "file": "quarterly_report_financial_tables.pdf",
+ "page_index": 0,
+ "table_index": 0,
+ "bbox": [
+ 0.148,
+ 0.088,
+ 0.894,
+ 0.335
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 6,
+ "cols": 5,
+ "span_signature": [
+ [
+ 3,
+ 2,
+ 1,
+ 2
+ ],
+ [
+ 4,
+ 2,
+ 1,
+ 2
+ ],
+ [
+ 5,
+ 2,
+ 1,
+ 2
+ ]
+ ],
+ "text_sha256": "0cb3edbf1b1b5f1a3feb6521b4d9acbde71c1d9205e406b019e1a9b72b14228b"
+ },
+ {
+ "file": "quarterly_report_financial_tables.pdf",
+ "page_index": 0,
+ "table_index": 1,
+ "bbox": [
+ 0.148,
+ 0.427,
+ 0.894,
+ 0.879
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 10,
+ "cols": 4,
+ "span_signature": [],
+ "text_sha256": "6dce9f81f9858da39dce0d0bf4cc166dbf514347c383877b4dfe8831514fadac"
+ },
+ {
+ "file": "quarterly_report_financial_tables.pdf",
+ "page_index": 1,
+ "table_index": 0,
+ "bbox": [
+ 0.148,
+ 0.089,
+ 0.894,
+ 0.676
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 17,
+ "cols": 4,
+ "span_signature": [],
+ "text_sha256": "2e5eb09dc9ca8c33568a23e95958773a4d2fab956e9be87b30691b81aa6c74be"
+ },
+ {
+ "file": "quarterly_report_financial_tables.pdf",
+ "page_index": 1,
+ "table_index": 1,
+ "bbox": [
+ 0.149,
+ 0.833,
+ 0.893,
+ 0.892
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 2,
+ "cols": 3,
+ "span_signature": [],
+ "text_sha256": "94867057db096b7d71f2b7f0d6d0ff8d1437de8ce151094ac623c1a753de6a92"
+ },
+ {
+ "file": "fund_manager_profile_table.pdf",
+ "page_index": 0,
+ "table_index": 0,
+ "bbox": [
+ 0.127,
+ 0.862,
+ 0.872,
+ 0.923
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 3,
+ "cols": 6,
+ "span_signature": [
+ [
+ 0,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 2,
+ 1,
+ 2
+ ],
+ [
+ 0,
+ 4,
+ 2,
+ 1
+ ],
+ [
+ 0,
+ 5,
+ 2,
+ 1
+ ]
+ ],
+ "text_sha256": "7bf9d4a2d906bec5baf64375e737dc4eb4d7f5097b60f019fde39dbd2a41198e"
+ },
+ {
+ "file": "fund_manager_profile_table.pdf",
+ "page_index": 1,
+ "table_index": 0,
+ "bbox": [
+ 0.127,
+ 0.084,
+ 0.873,
+ 0.457
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "rows": 1,
+ "cols": 6,
+ "span_signature": [],
+ "text_sha256": "babbe430014e5944e51e9f25da1d520ef0439c5b40bd1097edc270adbd16f3e3"
+ },
+ {
+ "file": "fund_asset_and_transaction_tables.pdf",
+ "page_index": 0,
+ "table_index": 0,
+ "bbox": [
+ 0.127,
+ 0.344,
+ 0.873,
+ 0.502
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 8,
+ "cols": 3,
+ "span_signature": [],
+ "text_sha256": "51e058a89c37feffd56978170bc12e9d0187fba8034bc13c8ce7e6305c85f765"
+ },
+ {
+ "file": "fund_asset_and_transaction_tables.pdf",
+ "page_index": 0,
+ "table_index": 1,
+ "bbox": [
+ 0.126,
+ 0.629,
+ 0.871,
+ 0.912
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 3,
+ "cols": 5,
+ "span_signature": [],
+ "text_sha256": "d53eebe2b7d99c132553288faa2e8c640d7b42dd64f7871d768e4a207fb25a57"
+ },
+ {
+ "file": "fund_asset_and_transaction_tables.pdf",
+ "page_index": 1,
+ "table_index": 0,
+ "bbox": [
+ 0.125,
+ 0.083,
+ 0.873,
+ 0.699
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 3,
+ "cols": 5,
+ "span_signature": [],
+ "text_sha256": "48a2c768df7a1c9ff7f2c434c6c1dfee2283e1a0c8c485d838e999df6b09dba2"
+ },
+ {
+ "file": "fund_asset_and_transaction_tables.pdf",
+ "page_index": 1,
+ "table_index": 1,
+ "bbox": [
+ 0.127,
+ 0.799,
+ 0.873,
+ 0.917
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 3,
+ "cols": 6,
+ "span_signature": [],
+ "text_sha256": "142abff4014383f56e8fb81443fe19554f4c3e4960756d504c4a0670a20030e6"
+ },
+ {
+ "file": "engineering_process_restrictions_table.pdf",
+ "page_index": 0,
+ "table_index": 0,
+ "bbox": [
+ 0.052,
+ 0.131,
+ 0.946,
+ 0.919
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 10,
+ "cols": 7,
+ "span_signature": [
+ [
+ 1,
+ 0,
+ 1,
+ 6
+ ]
+ ],
+ "text_sha256": "03920f1c17f81c79754c045187daccba62c5e29249e5a6d44cdfa5869104af2f"
+ },
+ {
+ "file": "engineering_process_restrictions_table.pdf",
+ "page_index": 1,
+ "table_index": 0,
+ "bbox": [
+ 0.052,
+ 0.079,
+ 0.946,
+ 0.93
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 11,
+ "cols": 7,
+ "span_signature": [
+ [
+ 3,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 3,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 3,
+ 5,
+ 2,
+ 1
+ ],
+ [
+ 3,
+ 6,
+ 2,
+ 1
+ ],
+ [
+ 5,
+ 0,
+ 1,
+ 6
+ ]
+ ],
+ "text_sha256": "cf58d4b97f4f4f0aa18a51b2991e45044131e0b24de417f5af5c56195da8338c"
+ },
+ {
+ "file": "engineering_process_restrictions_table.pdf",
+ "page_index": 2,
+ "table_index": 0,
+ "bbox": [
+ 0.052,
+ 0.079,
+ 0.946,
+ 0.921
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 10,
+ "cols": 7,
+ "span_signature": [
+ [
+ 8,
+ 0,
+ 1,
+ 6
+ ]
+ ],
+ "text_sha256": "1ce8fcd3d6ce5f37ed5fc0a4bb8ec55ce1b93e612c5b593dc5b259e5a5f78e3a"
+ },
+ {
+ "file": "engineering_process_restrictions_table.pdf",
+ "page_index": 3,
+ "table_index": 0,
+ "bbox": [
+ 0.052,
+ 0.079,
+ 0.946,
+ 0.92
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 10,
+ "cols": 7,
+ "span_signature": [
+ [
+ 8,
+ 0,
+ 1,
+ 6
+ ]
+ ],
+ "text_sha256": "4d30eb5754ad23ffa49865ffc25388adea00e5357bedc743d3654cfb417f3038"
+ },
+ {
+ "file": "engineering_process_restrictions_table.pdf",
+ "page_index": 4,
+ "table_index": 0,
+ "bbox": [
+ 0.052,
+ 0.08,
+ 0.947,
+ 0.909
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 4,
+ "cols": 7,
+ "span_signature": [
+ [
+ 1,
+ 0,
+ 1,
+ 6
+ ]
+ ],
+ "text_sha256": "3a9cb6a16b0feb1c82f5c93f4406fb1215708142c725aa89aa5692733b44b967"
+ },
+ {
+ "file": "engineering_process_restrictions_table.pdf",
+ "page_index": 5,
+ "table_index": 0,
+ "bbox": [
+ 0.052,
+ 0.08,
+ 0.946,
+ 0.914
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 7,
+ "cols": 7,
+ "span_signature": [
+ [
+ 2,
+ 0,
+ 3,
+ 1
+ ],
+ [
+ 2,
+ 1,
+ 3,
+ 1
+ ],
+ [
+ 2,
+ 5,
+ 3,
+ 1
+ ],
+ [
+ 2,
+ 6,
+ 3,
+ 1
+ ],
+ [
+ 5,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 5,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 5,
+ 3,
+ 2,
+ 1
+ ],
+ [
+ 5,
+ 4,
+ 2,
+ 1
+ ],
+ [
+ 5,
+ 5,
+ 2,
+ 1
+ ],
+ [
+ 5,
+ 6,
+ 2,
+ 1
+ ]
+ ],
+ "text_sha256": "fb1dd5694f1e98481dce883905c377d940d2d262a06a43123befeed68037a5e1"
+ },
+ {
+ "file": "engineering_process_restrictions_table.pdf",
+ "page_index": 6,
+ "table_index": 0,
+ "bbox": [
+ 0.052,
+ 0.08,
+ 0.946,
+ 0.924
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 8,
+ "cols": 7,
+ "span_signature": [
+ [
+ 1,
+ 0,
+ 3,
+ 1
+ ],
+ [
+ 1,
+ 1,
+ 3,
+ 1
+ ],
+ [
+ 1,
+ 5,
+ 3,
+ 1
+ ],
+ [
+ 1,
+ 6,
+ 3,
+ 1
+ ]
+ ],
+ "text_sha256": "c79dc528a20e014af933f94a2ce051a54b3981d5c267c95cd1ed4bbf81ff5c9f"
+ },
+ {
+ "file": "engineering_process_restrictions_table.pdf",
+ "page_index": 7,
+ "table_index": 0,
+ "bbox": [
+ 0.052,
+ 0.079,
+ 0.946,
+ 0.924
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 10,
+ "cols": 7,
+ "span_signature": [
+ [
+ 1,
+ 0,
+ 2,
+ 1
+ ],
+ [
+ 1,
+ 1,
+ 2,
+ 1
+ ],
+ [
+ 1,
+ 5,
+ 2,
+ 1
+ ],
+ [
+ 1,
+ 6,
+ 2,
+ 1
+ ],
+ [
+ 4,
+ 0,
+ 5,
+ 1
+ ],
+ [
+ 4,
+ 1,
+ 5,
+ 1
+ ],
+ [
+ 4,
+ 5,
+ 2,
+ 1
+ ],
+ [
+ 4,
+ 6,
+ 5,
+ 1
+ ],
+ [
+ 5,
+ 2,
+ 2,
+ 1
+ ],
+ [
+ 5,
+ 4,
+ 2,
+ 1
+ ],
+ [
+ 6,
+ 5,
+ 3,
+ 1
+ ]
+ ],
+ "text_sha256": "ef769af78876fd1c41c729515ac2c86f847e81517d433386839ccaffb3af9abd"
+ },
+ {
+ "file": "engineering_process_restrictions_table.pdf",
+ "page_index": 8,
+ "table_index": 0,
+ "bbox": [
+ 0.052,
+ 0.079,
+ 0.946,
+ 0.925
+ ],
+ "expected_output": "html",
+ "review_status": "legacy_unverified",
+ "rows": 8,
+ "cols": 7,
+ "span_signature": [],
+ "text_sha256": "347dd5bc006f7f7545a522f067dec7352d83d7c5a96face2692a47712cd12cd7"
+ }
+ ],
+ "flash_targets": [
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 4,
+ "table_index": 0,
+ "bbox_points": [
+ 65.8499984741211,
+ 116.11700439453125,
+ 776.0500106811523,
+ 299.91700744628906
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "target_reason": "localized_alias_blank_row",
+ "rows": 8,
+ "cols": 20,
+ "span_signature": [
+ [
+ 0,
+ 1,
+ 1,
+ 2
+ ],
+ [
+ 0,
+ 3,
+ 1,
+ 2
+ ],
+ [
+ 0,
+ 5,
+ 1,
+ 2
+ ],
+ [
+ 0,
+ 7,
+ 1,
+ 3
+ ],
+ [
+ 0,
+ 10,
+ 1,
+ 2
+ ],
+ [
+ 0,
+ 12,
+ 1,
+ 2
+ ],
+ [
+ 0,
+ 14,
+ 1,
+ 2
+ ],
+ [
+ 0,
+ 16,
+ 1,
+ 2
+ ],
+ [
+ 0,
+ 18,
+ 1,
+ 2
+ ],
+ [
+ 1,
+ 0,
+ 1,
+ 20
+ ],
+ [
+ 2,
+ 0,
+ 3,
+ 1
+ ],
+ [
+ 2,
+ 1,
+ 3,
+ 2
+ ],
+ [
+ 2,
+ 3,
+ 3,
+ 2
+ ],
+ [
+ 2,
+ 5,
+ 1,
+ 2
+ ],
+ [
+ 2,
+ 7,
+ 1,
+ 3
+ ],
+ [
+ 2,
+ 10,
+ 1,
+ 2
+ ],
+ [
+ 2,
+ 12,
+ 1,
+ 2
+ ],
+ [
+ 2,
+ 14,
+ 1,
+ 2
+ ],
+ [
+ 2,
+ 16,
+ 1,
+ 2
+ ],
+ [
+ 2,
+ 18,
+ 1,
+ 2
+ ],
+ [
+ 3,
+ 5,
+ 1,
+ 2
+ ],
+ [
+ 3,
+ 7,
+ 1,
+ 3
+ ],
+ [
+ 3,
+ 10,
+ 1,
+ 2
+ ],
+ [
+ 3,
+ 12,
+ 1,
+ 2
+ ],
+ [
+ 3,
+ 14,
+ 1,
+ 2
+ ],
+ [
+ 3,
+ 16,
+ 1,
+ 2
+ ],
+ [
+ 3,
+ 18,
+ 1,
+ 2
+ ],
+ [
+ 4,
+ 5,
+ 1,
+ 2
+ ],
+ [
+ 4,
+ 7,
+ 1,
+ 3
+ ],
+ [
+ 4,
+ 10,
+ 1,
+ 2
+ ],
+ [
+ 4,
+ 12,
+ 1,
+ 2
+ ],
+ [
+ 4,
+ 14,
+ 1,
+ 2
+ ],
+ [
+ 4,
+ 16,
+ 1,
+ 2
+ ],
+ [
+ 4,
+ 18,
+ 1,
+ 2
+ ],
+ [
+ 5,
+ 0,
+ 1,
+ 20
+ ],
+ [
+ 6,
+ 2,
+ 1,
+ 2
+ ],
+ [
+ 6,
+ 4,
+ 1,
+ 2
+ ],
+ [
+ 6,
+ 6,
+ 1,
+ 2
+ ],
+ [
+ 6,
+ 9,
+ 1,
+ 2
+ ],
+ [
+ 6,
+ 11,
+ 1,
+ 2
+ ],
+ [
+ 6,
+ 13,
+ 1,
+ 2
+ ],
+ [
+ 6,
+ 15,
+ 1,
+ 2
+ ],
+ [
+ 6,
+ 17,
+ 1,
+ 2
+ ],
+ [
+ 7,
+ 0,
+ 1,
+ 20
+ ]
+ ],
+ "text_sha256": "4a8cd5fa0282d84710832ac77a3d17f0c7777a9bb68eeeb5ad5efcc920a2f217"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 46,
+ "table_index": 0,
+ "bbox_points": [
+ 58.29999923706055,
+ 89.85000610351562,
+ 783.5999870300293,
+ 349.9499816894531
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "target_reason": "strong_single_column_line_grid",
+ "rows": 5,
+ "cols": 1,
+ "span_signature": [],
+ "text_sha256": "9a45006a8964a521e15842c4cf9b32e5ed7e22f2c9e03a3d50dc1f44572c624b"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 52,
+ "table_index": 0,
+ "bbox_points": [
+ 65.55000305175781,
+ 89.85002136230469,
+ 776.3499908447266,
+ 191.13401794433594
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "target_reason": "strong_single_column_line_grid",
+ "rows": 2,
+ "cols": 1,
+ "span_signature": [],
+ "text_sha256": "78f42aea1b91cdb6f9c10e211e0154cff1e0f13140731f47ebf6bfaa17099430"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 58,
+ "table_index": 0,
+ "bbox_points": [
+ 65.8499984741211,
+ 105.60000610351562,
+ 769.0500106811523,
+ 370.8340148925781
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "target_reason": "strong_single_column_line_grid",
+ "rows": 6,
+ "cols": 1,
+ "span_signature": [],
+ "text_sha256": "064700a9efac905c389491468a41b894b19b743efda3afca52482411bcac11f0"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 62,
+ "table_index": 0,
+ "bbox_points": [
+ 69.3499984741211,
+ 90.0,
+ 772.5500106811523,
+ 237.0500030517578
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "target_reason": "outer_edge_duplicate_track",
+ "rows": 4,
+ "cols": 10,
+ "span_signature": [
+ [
+ 1,
+ 0,
+ 1,
+ 10
+ ],
+ [
+ 2,
+ 0,
+ 1,
+ 10
+ ],
+ [
+ 3,
+ 0,
+ 1,
+ 10
+ ]
+ ],
+ "text_sha256": "2f7304ac1be915f56b615e8b28f27fb7cfecabe2da474dc7e3140e9340c649a6"
+ },
+ {
+ "file": "pollutant_discharge_tables.pdf",
+ "page_index": 63,
+ "table_index": 0,
+ "bbox_points": [
+ 69.3499984741211,
+ 90.0,
+ 772.5500106811523,
+ 239.5
+ ],
+ "expected_output": "html",
+ "review_status": "target_verified",
+ "target_reason": "outer_edge_duplicate_track",
+ "rows": 5,
+ "cols": 10,
+ "span_signature": [
+ [
+ 2,
+ 0,
+ 1,
+ 10
+ ],
+ [
+ 3,
+ 0,
+ 1,
+ 10
+ ],
+ [
+ 4,
+ 0,
+ 1,
+ 10
+ ]
+ ],
+ "text_sha256": "8cfdf6818cb161bbe5cfe7bddf7fdbf219e63a23c815d0bc488005c144760611"
+ }
+ ],
+ "accuracy_scope": "targeted_only",
+ "target_verified_tables": 41,
+ "legacy_unverified_tables": 92
+}
diff --git a/tests/unittest/pdfs/native_pdf_tables/README.md b/tests/unittest/pdfs/native_pdf_tables/README.md
new file mode 100644
index 00000000..71e2e702
--- /dev/null
+++ b/tests/unittest/pdfs/native_pdf_tables/README.md
@@ -0,0 +1,24 @@
+# Native PDF Table 真实语料
+
+本目录保存 Native PDF 表格结构恢复的仓库内回归输入。文件名采用稳定的英文语义名,评测真值位于 `tests/fixtures/native_pdf_table_cross_page_manifest.json`。
+
+| 文件 | 页数 | 场景 |
+|---|---:|---|
+| `conference_schedule_tables.pdf` | 12 | 会议日程中的多页规则表格 |
+| `manufacturing_facilities_cross_page_table.pdf` | 2 | 生产设施跨页表格 |
+| `procurement_document_blank_page_tables.pdf` | 4 | 含空白页的采购文档表格 |
+| `pollutant_discharge_tables.pdf` | 89 | 排污许可多样式表格 |
+| `procurement_contract_tables.pdf` | 2 | 采购合同付款及账户表格 |
+| `annual_report_research_projects_table.pdf` | 2 | 年报研发项目跨页表格 |
+| `annual_report_fundraising_projects_table.pdf` | 2 | 年报募投项目跨页表格 |
+| `annual_report_management_roles_table.pdf` | 2 | 年报任职情况跨页表格 |
+| `quarterly_report_financial_tables.pdf` | 2 | 季报财务数据跨页表格 |
+| `fund_manager_profile_table.pdf` | 2 | 基金经理简介跨页表格 |
+| `fund_asset_and_transaction_tables.pdf` | 2 | 基金资产及交易表格 |
+| `engineering_process_restrictions_table.pdf` | 9 | 工艺禁限用目录跨页表格 |
+
+## 隐私处理
+
+- 所有 PDF 均通过逐页重写移除了文档信息字典和 XMP 元数据,包括 Title、Author、Subject、Keywords、Creator、Producer 和日期字段。
+- `pollutant_discharge_tables.pdf` 仅保留原文档第 3 页及之后的页面;含企业与个人信息的前两页未进入仓库。
+- 除上述裁页外,页面可见内容、页面尺寸、旋转和绘图对象保持不变,并由结构真值与渲染回归共同校验。
diff --git a/tests/unittest/pdfs/native_pdf_tables/annual_report_fundraising_projects_table.pdf b/tests/unittest/pdfs/native_pdf_tables/annual_report_fundraising_projects_table.pdf
new file mode 100644
index 00000000..50239b7f
Binary files /dev/null and b/tests/unittest/pdfs/native_pdf_tables/annual_report_fundraising_projects_table.pdf differ
diff --git a/tests/unittest/pdfs/native_pdf_tables/annual_report_management_roles_table.pdf b/tests/unittest/pdfs/native_pdf_tables/annual_report_management_roles_table.pdf
new file mode 100644
index 00000000..4b538f9a
Binary files /dev/null and b/tests/unittest/pdfs/native_pdf_tables/annual_report_management_roles_table.pdf differ
diff --git a/tests/unittest/pdfs/native_pdf_tables/annual_report_research_projects_table.pdf b/tests/unittest/pdfs/native_pdf_tables/annual_report_research_projects_table.pdf
new file mode 100644
index 00000000..3d6d8a68
Binary files /dev/null and b/tests/unittest/pdfs/native_pdf_tables/annual_report_research_projects_table.pdf differ
diff --git a/tests/unittest/pdfs/native_pdf_tables/conference_schedule_tables.pdf b/tests/unittest/pdfs/native_pdf_tables/conference_schedule_tables.pdf
new file mode 100644
index 00000000..87a7f15d
Binary files /dev/null and b/tests/unittest/pdfs/native_pdf_tables/conference_schedule_tables.pdf differ
diff --git a/tests/unittest/pdfs/native_pdf_tables/engineering_process_restrictions_table.pdf b/tests/unittest/pdfs/native_pdf_tables/engineering_process_restrictions_table.pdf
new file mode 100644
index 00000000..0ea2a883
Binary files /dev/null and b/tests/unittest/pdfs/native_pdf_tables/engineering_process_restrictions_table.pdf differ
diff --git a/tests/unittest/pdfs/native_pdf_tables/fund_asset_and_transaction_tables.pdf b/tests/unittest/pdfs/native_pdf_tables/fund_asset_and_transaction_tables.pdf
new file mode 100644
index 00000000..ce872129
Binary files /dev/null and b/tests/unittest/pdfs/native_pdf_tables/fund_asset_and_transaction_tables.pdf differ
diff --git a/tests/unittest/pdfs/native_pdf_tables/fund_manager_profile_table.pdf b/tests/unittest/pdfs/native_pdf_tables/fund_manager_profile_table.pdf
new file mode 100644
index 00000000..f1b7c5e3
Binary files /dev/null and b/tests/unittest/pdfs/native_pdf_tables/fund_manager_profile_table.pdf differ
diff --git a/tests/unittest/pdfs/native_pdf_tables/manufacturing_facilities_cross_page_table.pdf b/tests/unittest/pdfs/native_pdf_tables/manufacturing_facilities_cross_page_table.pdf
new file mode 100644
index 00000000..42550b30
Binary files /dev/null and b/tests/unittest/pdfs/native_pdf_tables/manufacturing_facilities_cross_page_table.pdf differ
diff --git a/tests/unittest/pdfs/native_pdf_tables/pollutant_discharge_tables.pdf b/tests/unittest/pdfs/native_pdf_tables/pollutant_discharge_tables.pdf
new file mode 100644
index 00000000..0229b3b7
Binary files /dev/null and b/tests/unittest/pdfs/native_pdf_tables/pollutant_discharge_tables.pdf differ
diff --git a/tests/unittest/pdfs/native_pdf_tables/procurement_contract_tables.pdf b/tests/unittest/pdfs/native_pdf_tables/procurement_contract_tables.pdf
new file mode 100644
index 00000000..bfe45232
Binary files /dev/null and b/tests/unittest/pdfs/native_pdf_tables/procurement_contract_tables.pdf differ
diff --git a/tests/unittest/pdfs/native_pdf_tables/procurement_document_blank_page_tables.pdf b/tests/unittest/pdfs/native_pdf_tables/procurement_document_blank_page_tables.pdf
new file mode 100644
index 00000000..b547f843
Binary files /dev/null and b/tests/unittest/pdfs/native_pdf_tables/procurement_document_blank_page_tables.pdf differ
diff --git a/tests/unittest/pdfs/native_pdf_tables/quarterly_report_financial_tables.pdf b/tests/unittest/pdfs/native_pdf_tables/quarterly_report_financial_tables.pdf
new file mode 100644
index 00000000..70306083
Binary files /dev/null and b/tests/unittest/pdfs/native_pdf_tables/quarterly_report_financial_tables.pdf differ
diff --git a/tests/unittest/test_backend_architecture.py b/tests/unittest/test_backend_architecture.py
index 4bdfceb0..f8f25443 100644
--- a/tests/unittest/test_backend_architecture.py
+++ b/tests/unittest/test_backend_architecture.py
@@ -11,6 +11,7 @@ _CHINESE_DOCSTRING_EXTRA_PATHS = (
"mineru/model/flash/office",
"mineru/model/flash/xycut.py",
"mineru/model/model_types.py",
+ "mineru/utils/native_pdf_table",
"mineru/utils/spatial_text.py",
"mineru/utils/text_utils.py",
)
diff --git a/tests/unittest/test_flash_pdf_samples.py b/tests/unittest/test_flash_pdf_samples.py
index a865d119..1427312b 100644
--- a/tests/unittest/test_flash_pdf_samples.py
+++ b/tests/unittest/test_flash_pdf_samples.py
@@ -7,6 +7,7 @@ from copy import deepcopy
from pathlib import Path
from typing import Any
+from bs4 import BeautifulSoup
from pypdf import PdfReader
from mineru.backend.postprocess.page_blocks import process_page_blocks
@@ -173,9 +174,24 @@ def _visible_content(value: Any) -> str:
"""返回 model block 或 content 字符串去除行内样式协议后的可见文本。"""
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(" ")
return inline_plain_text(parse_inline_content(str(content or "")))
+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")
+ ]
+
+
def _normalized_content_probe(text: str) -> str:
"""还原 LaTeX tag 并去除排版差异,生成原生行内容覆盖检查使用的探针。"""
@@ -746,15 +762,7 @@ def test_demo2_table_captions_and_numeric_footnotes_are_independent_blocks() ->
("RealTimeGPU [5]", "Radeon XL1800", "52.8", "21", "9.82"),
("DCBGrid [19]", "Quadro FX 5800", "25.1", "10", "10.90"),
]
- table2_lines = page5_table["content"].splitlines()
- assert len(table2_lines) == len(expected_table2_rows)
- for line, expected_cells in zip(
- table2_lines,
- expected_table2_rows,
- strict=True,
- ):
- cell_offsets = [line.index(cell) for cell in expected_cells]
- assert cell_offsets == sorted(cell_offsets)
+ assert _html_table_rows(page5_table["content"]) == expected_table2_rows
assert "6.20CostFilter [10]" not in page5_table["content"]
assert "ral stereo matching." not in residual_text
assert "Millions of Disparity Estimates per Second." not in residual_text
@@ -1484,9 +1492,9 @@ def test_synthetic_flash_table_annotation_regressions() -> None:
[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 [_html_table_rows(block["content"])[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"],
diff --git a/tests/unittest/test_native_pdf_table.py b/tests/unittest/test_native_pdf_table.py
new file mode 100644
index 00000000..d428bd6d
--- /dev/null
+++ b/tests/unittest/test_native_pdf_table.py
@@ -0,0 +1,1627 @@
+# Copyright (c) Opendatalab. All rights reserved.
+"""验证 Native PDF 表格结构恢复的网格、文本和候选仲裁。"""
+
+from __future__ import annotations
+
+from collections.abc import Iterable
+from io import BytesIO
+
+import pytest
+from reportlab.pdfgen.canvas import Canvas
+
+from mineru.utils.native_pdf_table import (
+ NativeTableCell,
+ NativeTableInput,
+ NativeTableRectangle,
+ NativeTableRule,
+ coerce_native_table_rectangles,
+ coerce_native_table_rules,
+ recover_native_pdf_table,
+)
+from mineru.utils.native_pdf_table.contracts import NativeTableCandidate
+from mineru.utils.native_pdf_table.engine import (
+ _remove_undercounted_vector_candidates,
+ _select_candidate,
+ diagnose_native_pdf_table,
+)
+from mineru.utils.native_pdf_table.text import build_native_table_text
+from mineru.utils.native_pdf_table.vector import (
+ MAX_PRIMITIVES_PER_TABLE,
+ build_vector_candidates,
+)
+from mineru.utils.pdf_document import PDFDocument
+
+
+def _char_items(
+ entries: Iterable[tuple[str, tuple[float, float, float, float]]],
+) -> tuple[dict[str, object], ...]:
+ """把文本框拆成带稳定 char_idx 的逐字符测试输入。"""
+
+ rebuilt: list[dict[str, object]] = []
+ for text, bbox in entries:
+ left, top, right, bottom = bbox
+ char_width = (right - left) / max(1, len(text))
+ for offset, char in enumerate(text):
+ rebuilt.append(
+ {
+ "char": char,
+ "bbox": (
+ left + char_width * offset,
+ top,
+ left + char_width * (offset + 1),
+ bottom,
+ ),
+ "char_idx": len(rebuilt),
+ }
+ )
+ return tuple(rebuilt)
+
+
+def _grid_rules(
+ *,
+ width: float = 100.0,
+ height: float = 60.0,
+ internal_vertical: tuple[float, float] = (0.0, 60.0),
+ internal_horizontal: tuple[float, float] = (0.0, 100.0),
+) -> tuple[NativeTableRule, ...]:
+ """构造二行二列表格边框,并允许裁剪内部横竖隔断。"""
+
+ return (
+ NativeTableRule((0.0, 0.0, width, 1.0), 1.0, "horizontal"),
+ NativeTableRule(
+ (internal_horizontal[0], 29.5, internal_horizontal[1], 30.5),
+ 1.0,
+ "horizontal",
+ ),
+ NativeTableRule((0.0, height - 1.0, width, height), 1.0, "horizontal"),
+ NativeTableRule((0.0, 0.0, 1.0, height), 1.0, "vertical"),
+ NativeTableRule(
+ (49.5, internal_vertical[0], 50.5, internal_vertical[1]),
+ 1.0,
+ "vertical",
+ ),
+ NativeTableRule((width - 1.0, 0.0, width, height), 1.0, "vertical"),
+ )
+
+
+def _local_to_page_bbox(
+ bbox: tuple[float, float, float, float],
+ page_width: float,
+ page_height: float,
+ angle: int,
+) -> tuple[float, float, float, float]:
+ """把正向局部测试框逆变换回页面坐标。"""
+
+ x0, y0, x1, y1 = bbox
+ if angle == 90:
+ return page_width - y1, x0, page_width - y0, x1
+ if angle == 270:
+ return y0, page_height - x1, y1, page_height - x0
+ if angle == 180:
+ return page_width - x1, page_height - y1, page_width - x0, page_height - y0
+ return bbox
+
+
+def _aligned_text_input(
+ rows: list[list[str | None]],
+ *,
+ angle: int = 0,
+ rules: tuple[NativeTableRule, ...] = (),
+ rectangles: tuple[NativeTableRectangle, ...] = (),
+) -> NativeTableInput:
+ """构造标准旋转下的等距文本表格输入。"""
+
+ page_width, page_height = 120.0, 90.0
+ local_width, local_height = (page_height, page_width) if angle in {90, 270} else (page_width, page_height)
+ col_count = max(len(row) for row in rows)
+ x_positions = [local_width * (0.10 + 0.75 * col / max(1, col_count - 1)) for col in range(col_count)]
+ y_positions = [local_height * (0.12 + 0.70 * row / max(1, len(rows) - 1)) for row in range(len(rows))]
+ entries = []
+ for row_index, row in enumerate(rows):
+ for col_index, text in enumerate(row):
+ if text is None:
+ continue
+ width = max(4.0, min(local_width * 0.20, len(text) * 4.0))
+ local_bbox = (
+ x_positions[col_index],
+ y_positions[row_index],
+ min(local_width - 1.0, x_positions[col_index] + width),
+ min(local_height - 1.0, y_positions[row_index] + 8.0),
+ )
+ entries.append(
+ (
+ text,
+ _local_to_page_bbox(
+ local_bbox,
+ page_width,
+ page_height,
+ angle,
+ ),
+ )
+ )
+ return NativeTableInput(
+ table_bbox=(0.0, 0.0, page_width, page_height),
+ page_size=(page_width, page_height),
+ angle=angle,
+ chars=_char_items(entries),
+ drawing_lines=rules,
+ rectangles=rectangles,
+ )
+
+
+def _rotated_single_row_input(angle: int) -> NativeTableInput:
+ """构造四种标准旋转下的三列单物理行强线框。"""
+
+ page_width, page_height = 120.0, 90.0
+ local_width, local_height = (page_height, page_width) if angle in {90, 270} else (page_width, page_height)
+ x_tracks = (0.0, local_width / 3.0, 2.0 * local_width / 3.0, local_width)
+ local_rule_bboxes = [
+ (0.0, 0.0, local_width, 1.0),
+ (0.0, local_height - 1.0, local_width, local_height),
+ *((x - 0.5, 0.0, x + 0.5, local_height) for x in x_tracks),
+ ]
+ page_rule_bboxes = [
+ _local_to_page_bbox(
+ bbox,
+ page_width,
+ page_height,
+ angle,
+ )
+ for bbox in local_rule_bboxes
+ ]
+ rules = tuple(
+ NativeTableRule(
+ bbox,
+ 1.0,
+ "horizontal" if bbox[2] - bbox[0] >= bbox[3] - bbox[1] else "vertical",
+ )
+ for bbox in page_rule_bboxes
+ )
+ entries = []
+ for col, text in enumerate(("A", "B", "C")):
+ local_bbox = (
+ x_tracks[col] + 5.0,
+ 10.0,
+ x_tracks[col] + 10.0,
+ 18.0,
+ )
+ entries.append(
+ (
+ text,
+ _local_to_page_bbox(
+ local_bbox,
+ page_width,
+ page_height,
+ angle,
+ ),
+ )
+ )
+ return NativeTableInput(
+ table_bbox=(0.0, 0.0, page_width, page_height),
+ page_size=(page_width, page_height),
+ angle=angle,
+ chars=_char_items(entries),
+ drawing_lines=rules,
+ )
+
+
+def _rotated_single_column_input(angle: int) -> NativeTableInput:
+ """构造四种标准旋转下的二行单列强线框表单。"""
+
+ page_width, page_height = 120.0, 90.0
+ local_width, local_height = (page_height, page_width) if angle in {90, 270} else (page_width, page_height)
+ y_tracks = (0.0, local_height / 2.0, local_height)
+ local_rule_bboxes = [
+ *((0.0, y - 0.5, local_width, y + 0.5) for y in y_tracks),
+ (0.0, 0.0, 1.0, local_height),
+ (local_width - 1.0, 0.0, local_width, local_height),
+ ]
+ page_rule_bboxes = [
+ _local_to_page_bbox(
+ bbox,
+ page_width,
+ page_height,
+ angle,
+ )
+ for bbox in local_rule_bboxes
+ ]
+ rules = tuple(
+ NativeTableRule(
+ bbox,
+ 1.0,
+ "horizontal" if bbox[2] - bbox[0] >= bbox[3] - bbox[1] else "vertical",
+ )
+ for bbox in page_rule_bboxes
+ )
+ chars: list[dict[str, object]] = []
+ for row, text in enumerate(("A&B", "Value A B")):
+ top = row * local_height / 2.0 + 10.0
+ for offset, char in enumerate(text):
+ chars.append(
+ {
+ "char": char,
+ "bbox": _local_to_page_bbox(
+ (
+ 8.0 + 4.0 * offset,
+ top,
+ 12.0 + 4.0 * offset,
+ top + 8.0,
+ ),
+ page_width,
+ page_height,
+ angle,
+ ),
+ "char_idx": len(chars),
+ }
+ )
+ return NativeTableInput(
+ table_bbox=(0.0, 0.0, page_width, page_height),
+ page_size=(page_width, page_height),
+ angle=angle,
+ chars=tuple(chars),
+ drawing_lines=rules,
+ )
+
+
+def _candidate(
+ *,
+ source: str,
+ rows: int,
+ cols: int,
+ score: float,
+ issues: tuple[str, ...] = (),
+) -> NativeTableCandidate:
+ """构造候选仲裁测试需要的最小内部对象。"""
+
+ cells = tuple(
+ NativeTableCell(
+ row=row,
+ col=col,
+ rowspan=1,
+ colspan=1,
+ bbox=(float(col), float(row), float(col + 1), float(row + 1)),
+ content="",
+ )
+ for row in range(rows)
+ for col in range(cols)
+ )
+ return NativeTableCandidate(
+ source=source, # type: ignore[arg-type]
+ rows=rows,
+ cols=cols,
+ cells=cells,
+ score=score,
+ text_capture=1.0,
+ structure_support=1.0,
+ row_stability=1.0,
+ column_stability=1.0,
+ order_consistency=1.0,
+ issues=issues,
+ )
+
+
+def _build_reportlab_table_pdf() -> bytes:
+ """生成带真实 PDF drawing 和文本层的二行二列表格 fixture。"""
+
+ output = BytesIO()
+ canvas = Canvas(output, pagesize=(200, 200))
+ canvas.setLineWidth(1)
+ for y in (40, 100, 160):
+ canvas.line(20, y, 180, y)
+ for x in (20, 100, 180):
+ canvas.line(x, 40, x, 160)
+ canvas.drawString(35, 130, "A")
+ canvas.drawString(115, 130, "B")
+ canvas.drawString(35, 70, "C")
+ canvas.drawString(115, 70, "D")
+ canvas.showPage()
+ canvas.save()
+ return output.getvalue()
+
+
+def test_vector_grid_recovers_cells_and_escapes_html() -> None:
+ """验证完整矢量网格生成稳定 HTML,并转义单元格文本。"""
+
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 100.0, 60.0),
+ page_size=(100.0, 60.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("<&", (10.0, 10.0, 20.0, 18.0)),
+ ("B", (60.0, 10.0, 65.0, 18.0)),
+ ("C", (10.0, 40.0, 15.0, 48.0)),
+ ("D", (60.0, 40.0, 65.0, 48.0)),
+ ]
+ ),
+ drawing_lines=_grid_rules(),
+ )
+
+ result = recover_native_pdf_table(table_input)
+
+ assert result is not None
+ assert result.source == "vector_grid"
+ assert result.html == ("<table><tbody><tr><td>&lt;&amp;</td><td>B</td></tr><tr><td>C</td><td>D</td></tr></tbody></table>")
+ assert sorted(index for cell in result.cells for index in cell.source_char_indices) == [0, 1, 2, 3, 4]
+
+
+def test_vector_grid_splits_one_pdf_text_run_by_character_boundary() -> None:
+ """验证同一原生文本对象横跨两列时仍按逐字符 bbox 唯一落格。"""
+
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 100.0, 60.0),
+ page_size=(100.0, 60.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("AB", (45.0, 10.0, 55.0, 18.0)),
+ ("C", (10.0, 40.0, 15.0, 48.0)),
+ ("D", (60.0, 40.0, 65.0, 48.0)),
+ ]
+ ),
+ drawing_lines=_grid_rules(),
+ )
+
+ result = recover_native_pdf_table(table_input)
+
+ assert result is not None
+ assert "<tr><td>A</td><td>B</td></tr>" in result.html
+
+
+def test_vector_grid_accepts_open_outer_vertical_edges() -> None:
+ """验证横线端点可补齐缺失的左右外框而不伪造内部隔断。"""
+
+ rules = (
+ NativeTableRule((0.0, 0.0, 100.0, 1.0), 1.0, "horizontal"),
+ NativeTableRule((0.0, 29.5, 100.0, 30.5), 1.0, "horizontal"),
+ NativeTableRule((0.0, 59.0, 100.0, 60.0), 1.0, "horizontal"),
+ NativeTableRule((49.5, 0.0, 50.5, 60.0), 1.0, "vertical"),
+ )
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 100.0, 60.0),
+ page_size=(100.0, 60.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("A", (10.0, 10.0, 15.0, 18.0)),
+ ("B", (60.0, 10.0, 65.0, 18.0)),
+ ("C", (10.0, 40.0, 15.0, 48.0)),
+ ("D", (60.0, 40.0, 65.0, 48.0)),
+ ]
+ ),
+ drawing_lines=rules,
+ )
+
+ result = recover_native_pdf_table(table_input)
+
+ assert result is not None
+ assert result.source == "vector_grid"
+ assert (result.rows, result.cols) == (2, 2)
+
+
+def test_single_long_rule_endpoint_does_not_create_global_column() -> None:
+ """验证单条长横线的内缩端点不能创建全局幽灵列。"""
+
+ rules = list(_grid_rules())
+ rules[0] = NativeTableRule((10.0, 0.0, 100.0, 1.0), 1.0, "horizontal")
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 100.0, 60.0),
+ page_size=(100.0, 60.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("A", (10.0, 10.0, 15.0, 18.0)),
+ ("B", (60.0, 10.0, 65.0, 18.0)),
+ ("C", (10.0, 40.0, 15.0, 48.0)),
+ ("D", (60.0, 40.0, 65.0, 48.0)),
+ ]
+ ),
+ drawing_lines=tuple(rules),
+ )
+
+ result = recover_native_pdf_table(table_input)
+
+ assert result is not None
+ assert (result.rows, result.cols) == (2, 2)
+
+
+def test_vector_grid_joins_small_collinear_gaps() -> None:
+ """验证内部竖线的小间隙会先连接,不会误判为 colspan。"""
+
+ rules = tuple(rule for rule in _grid_rules() if not (rule.orientation == "vertical" and 49.0 <= rule.bbox[0] <= 51.0)) + (
+ NativeTableRule((49.5, 0.0, 50.5, 14.0), 1.0, "vertical"),
+ NativeTableRule((49.5, 16.0, 50.5, 60.0), 1.0, "vertical"),
+ )
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 100.0, 60.0),
+ page_size=(100.0, 60.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("A", (10.0, 10.0, 15.0, 18.0)),
+ ("B", (60.0, 10.0, 65.0, 18.0)),
+ ("C", (10.0, 40.0, 15.0, 48.0)),
+ ("D", (60.0, 40.0, 65.0, 48.0)),
+ ]
+ ),
+ drawing_lines=rules,
+ )
+
+ result = recover_native_pdf_table(table_input)
+
+ assert result is not None
+ assert "colspan" not in result.html
+
+
+def test_line_grid_ignores_stroked_rectangle_duplicate_tracks() -> None:
+ """验证 drawing 与描边矩形重复边界不会混成幽灵行列。"""
+
+ rectangles = tuple(
+ NativeTableRectangle(bbox, 5, False, True)
+ for bbox in (
+ (0.5, 0.5, 49.5, 29.5),
+ (50.5, 0.5, 99.5, 29.5),
+ (0.5, 30.5, 49.5, 59.5),
+ (50.5, 30.5, 99.5, 59.5),
+ )
+ )
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 100.0, 60.0),
+ page_size=(100.0, 60.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("A", (10.0, 10.0, 15.0, 18.0)),
+ ("B", (60.0, 10.0, 65.0, 18.0)),
+ ("C", (10.0, 40.0, 15.0, 48.0)),
+ ("D", (60.0, 40.0, 65.0, 48.0)),
+ ]
+ ),
+ drawing_lines=_grid_rules(),
+ rectangles=rectangles,
+ )
+
+ result = recover_native_pdf_table(table_input)
+
+ assert result is not None
+ assert (result.rows, result.cols) == (2, 2)
+ assert "evidence=line_grid" in result.diagnostics
+
+
+def test_rect_grid_requires_repeated_two_dimensional_lattice() -> None:
+ """验证四个重复单元格矩形可独立形成 rect_grid。"""
+
+ rectangles = tuple(
+ NativeTableRectangle(bbox, 5, True, False)
+ for bbox in (
+ (0.0, 0.0, 50.0, 30.0),
+ (50.0, 0.0, 100.0, 30.0),
+ (0.0, 30.0, 50.0, 60.0),
+ (50.0, 30.0, 100.0, 60.0),
+ )
+ )
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 100.0, 60.0),
+ page_size=(100.0, 60.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("A", (10.0, 10.0, 15.0, 18.0)),
+ ("B", (60.0, 10.0, 65.0, 18.0)),
+ ("C", (10.0, 40.0, 15.0, 48.0)),
+ ("D", (60.0, 40.0, 65.0, 48.0)),
+ ]
+ ),
+ rectangles=rectangles,
+ )
+
+ result = recover_native_pdf_table(table_input)
+
+ assert result is not None
+ assert (result.rows, result.cols) == (2, 2)
+ assert "evidence=rect_grid" in result.diagnostics
+
+
+def test_vector_grid_collapses_narrow_empty_duplicate_track() -> None:
+ """验证窄空列会保留较强真实边界并删除重复竖轨。"""
+
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 100.0, 60.0),
+ page_size=(100.0, 60.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("A", (10.0, 10.0, 15.0, 18.0)),
+ ("B", (60.0, 10.0, 65.0, 18.0)),
+ ("C", (10.0, 40.0, 15.0, 48.0)),
+ ("D", (60.0, 40.0, 65.0, 48.0)),
+ ]
+ ),
+ drawing_lines=(
+ *_grid_rules(),
+ NativeTableRule((50.5, 0.0, 51.5, 60.0), 1.0, "vertical"),
+ ),
+ )
+
+ result = recover_native_pdf_table(table_input)
+
+ assert result is not None
+ assert (result.rows, result.cols) == (2, 2)
+ assert "colspan" not in result.html
+
+
+def test_vector_grid_uses_aliases_for_offset_complementary_separators() -> None:
+ """验证表头正文错位的同一竖线折叠后仍按 alias 保持分隔。"""
+
+ rules = tuple(rule for rule in _grid_rules() if not (rule.orientation == "vertical" and 49.0 <= rule.bbox[0] <= 51.0)) + (
+ NativeTableRule((48.5, 0.0, 49.5, 30.0), 1.0, "vertical"),
+ NativeTableRule((50.5, 30.0, 51.5, 60.0), 1.0, "vertical"),
+ )
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 100.0, 60.0),
+ page_size=(100.0, 60.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("A", (10.0, 10.0, 15.0, 18.0)),
+ ("B", (60.0, 10.0, 65.0, 18.0)),
+ ("C", (10.0, 40.0, 15.0, 48.0)),
+ ("D", (60.0, 40.0, 65.0, 48.0)),
+ ]
+ ),
+ drawing_lines=rules,
+ )
+
+ result = recover_native_pdf_table(table_input)
+
+ assert result is not None
+ assert (result.rows, result.cols) == (2, 2)
+ assert "colspan" not in result.html
+ assert "alias_separator_recoveries=2" in result.diagnostics
+
+
+def test_vector_grid_rejects_non_unique_alias_chain() -> None:
+ """验证连续窄轨的 alias 总跨度超限时主动放弃。"""
+
+ rules = (
+ NativeTableRule((0.0, 0.0, 100.0, 1.0), 1.0, "horizontal"),
+ NativeTableRule((0.0, 29.5, 100.0, 30.5), 1.0, "horizontal"),
+ NativeTableRule((0.0, 59.0, 100.0, 60.0), 1.0, "horizontal"),
+ NativeTableRule((0.0, 0.0, 1.0, 60.0), 1.0, "vertical"),
+ NativeTableRule((44.5, 0.0, 45.5, 60.0), 1.0, "vertical"),
+ NativeTableRule((48.5, 0.0, 49.5, 60.0), 1.0, "vertical"),
+ NativeTableRule((52.5, 0.0, 53.5, 60.0), 1.0, "vertical"),
+ NativeTableRule((99.0, 0.0, 100.0, 60.0), 1.0, "vertical"),
+ )
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 100.0, 60.0),
+ page_size=(100.0, 60.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("A", (10.0, 10.0, 15.0, 18.0)),
+ ("B", (70.0, 10.0, 75.0, 18.0)),
+ ("C", (10.0, 40.0, 15.0, 48.0)),
+ ("D", (70.0, 40.0, 75.0, 48.0)),
+ ]
+ ),
+ drawing_lines=rules,
+ )
+
+ text = build_native_table_text(table_input)
+
+ assert text is not None
+ assert build_vector_candidates(table_input, text) == []
+
+
+def test_vector_grid_rejects_single_column_region_with_narrow_ghost_track() -> None:
+ """验证单列区域不能借一个窄空轨伪装成二列表格。"""
+
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 100.0, 60.0),
+ page_size=(100.0, 60.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("Header", (20.0, 10.0, 44.0, 18.0)),
+ ("Value", (20.0, 40.0, 40.0, 48.0)),
+ ]
+ ),
+ drawing_lines=(
+ NativeTableRule((0.0, 0.0, 100.0, 1.0), 1.0, "horizontal"),
+ NativeTableRule((0.0, 29.5, 100.0, 30.5), 1.0, "horizontal"),
+ NativeTableRule((0.0, 59.0, 100.0, 60.0), 1.0, "horizontal"),
+ NativeTableRule((4.5, 0.0, 5.5, 60.0), 1.0, "vertical"),
+ ),
+ )
+
+ text = build_native_table_text(table_input)
+
+ assert text is not None
+ assert build_vector_candidates(table_input, text) == []
+
+
+def test_vector_grid_accepts_one_text_row_with_blank_physical_row() -> None:
+ """验证强物理二行网格即使只有一行原生文本也可保留空白数据行。"""
+
+ rules = (
+ NativeTableRule((0.0, 0.0, 120.0, 1.0), 1.0, "horizontal"),
+ NativeTableRule((0.0, 29.5, 120.0, 30.5), 1.0, "horizontal"),
+ NativeTableRule((0.0, 59.0, 120.0, 60.0), 1.0, "horizontal"),
+ NativeTableRule((0.0, 0.0, 1.0, 60.0), 1.0, "vertical"),
+ NativeTableRule((39.5, 0.0, 40.5, 60.0), 1.0, "vertical"),
+ NativeTableRule((79.5, 0.0, 80.5, 60.0), 1.0, "vertical"),
+ NativeTableRule((119.0, 0.0, 120.0, 60.0), 1.0, "vertical"),
+ )
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 120.0, 60.0),
+ page_size=(120.0, 60.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("A", (10.0, 10.0, 14.0, 18.0)),
+ ("B", (50.0, 10.0, 54.0, 18.0)),
+ ("C", (90.0, 10.0, 94.0, 18.0)),
+ ]
+ ),
+ drawing_lines=rules,
+ )
+
+ result = recover_native_pdf_table(table_input)
+
+ assert result is not None
+ assert (result.rows, result.cols) == (2, 3)
+ assert result.html.endswith("<tr><td></td><td></td><td></td></tr></tbody></table>")
+
+
+def test_line_grid_accepts_multilevel_header_and_blank_template_row() -> None:
+ """验证强线框多层表头可保留全宽空白模板行。"""
+
+ rules = (
+ NativeTableRule((0.0, 0.0, 120.0, 1.0), 1.0, "horizontal"),
+ NativeTableRule((0.0, 19.5, 120.0, 20.5), 1.0, "horizontal"),
+ NativeTableRule((0.0, 39.5, 120.0, 40.5), 1.0, "horizontal"),
+ NativeTableRule((0.0, 59.0, 120.0, 60.0), 1.0, "horizontal"),
+ NativeTableRule((0.0, 0.0, 1.0, 60.0), 1.0, "vertical"),
+ NativeTableRule((39.5, 0.0, 40.5, 40.0), 1.0, "vertical"),
+ NativeTableRule((79.5, 0.0, 80.5, 40.0), 1.0, "vertical"),
+ NativeTableRule((119.0, 0.0, 120.0, 60.0), 1.0, "vertical"),
+ )
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 120.0, 60.0),
+ page_size=(120.0, 60.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("A", (10.0, 5.0, 14.0, 13.0)),
+ ("B", (50.0, 5.0, 54.0, 13.0)),
+ ("C", (90.0, 5.0, 94.0, 13.0)),
+ ("D", (10.0, 25.0, 14.0, 33.0)),
+ ("E", (50.0, 25.0, 54.0, 33.0)),
+ ("F", (90.0, 25.0, 94.0, 33.0)),
+ ]
+ ),
+ drawing_lines=rules,
+ )
+
+ result = recover_native_pdf_table(table_input)
+
+ assert result is not None
+ assert (result.rows, result.cols) == (3, 3)
+ assert result.confidence >= 0.95
+ assert result.html.endswith('<tr><td colspan="3"></td></tr></tbody></table>')
+ assert "physical_blank_rows=2" in result.diagnostics
+
+
+def test_line_grid_accepts_blank_row_when_alias_recovery_is_elsewhere() -> None:
+ """验证其他物理行的 alias 恢复不会误伤独立封闭的空白行。"""
+
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 120.0, 60.0),
+ page_size=(120.0, 60.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("A", (10.0, 5.0, 14.0, 13.0)),
+ ("B", (70.0, 5.0, 74.0, 13.0)),
+ ("C", (10.0, 25.0, 14.0, 33.0)),
+ ("D", (70.0, 25.0, 74.0, 33.0)),
+ ]
+ ),
+ drawing_lines=(
+ NativeTableRule((0.0, 0.0, 120.0, 1.0), 1.0, "horizontal"),
+ NativeTableRule((0.0, 19.5, 120.0, 20.5), 1.0, "horizontal"),
+ NativeTableRule((0.0, 39.5, 120.0, 40.5), 1.0, "horizontal"),
+ NativeTableRule((0.0, 59.0, 120.0, 60.0), 1.0, "horizontal"),
+ NativeTableRule((0.0, 0.0, 1.0, 60.0), 1.0, "vertical"),
+ NativeTableRule((48.5, 0.0, 49.5, 20.0), 1.0, "vertical"),
+ NativeTableRule((50.5, 20.0, 51.5, 40.0), 1.0, "vertical"),
+ NativeTableRule((119.0, 0.0, 120.0, 60.0), 1.0, "vertical"),
+ ),
+ )
+
+ result = recover_native_pdf_table(table_input)
+ diagnostics = diagnose_native_pdf_table(table_input)
+
+ assert result is not None
+ assert (result.rows, result.cols) == (3, 2)
+ assert result.html.endswith('<tr><td colspan="2"></td></tr></tbody></table>')
+ line_attempt = next(attempt for attempt in diagnostics["vector_attempts"] if attempt["evidence"] == "line_grid")
+ assert line_attempt["alias_affected_rows"] == [0, 1]
+ assert line_attempt["empty_rows"] == [2]
+
+
+def test_line_grid_rejects_blank_row_touched_by_alias_recovery() -> None:
+ """验证空白行自身依赖 alias separator 时仍主动回退。"""
+
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 120.0, 60.0),
+ page_size=(120.0, 60.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("A", (10.0, 5.0, 14.0, 13.0)),
+ ("B", (70.0, 5.0, 74.0, 13.0)),
+ ("C", (10.0, 25.0, 14.0, 33.0)),
+ ("D", (70.0, 25.0, 74.0, 33.0)),
+ ]
+ ),
+ drawing_lines=(
+ NativeTableRule((0.0, 0.0, 120.0, 1.0), 1.0, "horizontal"),
+ NativeTableRule((0.0, 19.5, 120.0, 20.5), 1.0, "horizontal"),
+ NativeTableRule((0.0, 39.5, 120.0, 40.5), 1.0, "horizontal"),
+ NativeTableRule((0.0, 59.0, 120.0, 60.0), 1.0, "horizontal"),
+ NativeTableRule((0.0, 0.0, 1.0, 60.0), 1.0, "vertical"),
+ NativeTableRule((48.5, 0.0, 49.5, 20.0), 1.0, "vertical"),
+ NativeTableRule((50.5, 20.0, 51.5, 40.0), 1.0, "vertical"),
+ NativeTableRule((48.5, 40.0, 49.5, 60.0), 1.0, "vertical"),
+ NativeTableRule((119.0, 0.0, 120.0, 60.0), 1.0, "vertical"),
+ ),
+ )
+
+ result = recover_native_pdf_table(table_input)
+ diagnostics = diagnose_native_pdf_table(table_input)
+ assert result is None
+ line_attempt = next(attempt for attempt in diagnostics["vector_attempts"] if attempt["evidence"] == "line_grid")
+ assert line_attempt["first_rejection_gate"] == "empty_row"
+ assert 2 in line_attempt["alias_affected_rows"]
+
+
+def test_line_grid_rejects_blank_row_without_bottom_boundary() -> None:
+ """验证缺少独立下边界的空白行不能借端点推断进入 HTML。"""
+
+ base = (
+ NativeTableRule((0.0, 0.0, 120.0, 1.0), 1.0, "horizontal"),
+ NativeTableRule((0.0, 19.5, 120.0, 20.5), 1.0, "horizontal"),
+ NativeTableRule((0.0, 39.5, 120.0, 40.5), 1.0, "horizontal"),
+ NativeTableRule((0.0, 0.0, 1.0, 60.0), 1.0, "vertical"),
+ NativeTableRule((39.5, 0.0, 40.5, 40.0), 1.0, "vertical"),
+ NativeTableRule((79.5, 0.0, 80.5, 40.0), 1.0, "vertical"),
+ NativeTableRule((119.0, 0.0, 120.0, 60.0), 1.0, "vertical"),
+ )
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 120.0, 60.0),
+ page_size=(120.0, 60.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("A", (10.0, 5.0, 14.0, 13.0)),
+ ("B", (50.0, 5.0, 54.0, 13.0)),
+ ("C", (90.0, 5.0, 94.0, 13.0)),
+ ("D", (10.0, 25.0, 14.0, 33.0)),
+ ("E", (50.0, 25.0, 54.0, 33.0)),
+ ("F", (90.0, 25.0, 94.0, 33.0)),
+ ]
+ ),
+ drawing_lines=base,
+ )
+
+ text = build_native_table_text(table_input)
+
+ assert text is not None
+ assert build_vector_candidates(table_input, text) == []
+ diagnostics = diagnose_native_pdf_table(table_input)
+ line_attempt = next(attempt for attempt in diagnostics["vector_attempts"] if attempt["evidence"] == "line_grid")
+ assert line_attempt["first_rejection_gate"] == "empty_row"
+ assert line_attempt["empty_rows"] == [2]
+
+
+def test_line_grid_rejects_too_narrow_blank_row() -> None:
+ """验证高度不足的空白物理行仍主动回退。"""
+
+ rules = (
+ NativeTableRule((0.0, 0.0, 120.0, 1.0), 1.0, "horizontal"),
+ NativeTableRule((0.0, 29.5, 120.0, 30.5), 1.0, "horizontal"),
+ NativeTableRule((0.0, 55.5, 120.0, 56.5), 1.0, "horizontal"),
+ NativeTableRule((0.0, 59.0, 120.0, 60.0), 1.0, "horizontal"),
+ NativeTableRule((0.0, 0.0, 1.0, 60.0), 1.0, "vertical"),
+ NativeTableRule((39.5, 0.0, 40.5, 56.0), 1.0, "vertical"),
+ NativeTableRule((79.5, 0.0, 80.5, 56.0), 1.0, "vertical"),
+ NativeTableRule((119.0, 0.0, 120.0, 60.0), 1.0, "vertical"),
+ )
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 120.0, 60.0),
+ page_size=(120.0, 60.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("A", (10.0, 8.0, 14.0, 16.0)),
+ ("B", (50.0, 8.0, 54.0, 16.0)),
+ ("C", (90.0, 8.0, 94.0, 16.0)),
+ ("D", (10.0, 38.0, 14.0, 46.0)),
+ ("E", (50.0, 38.0, 54.0, 46.0)),
+ ("F", (90.0, 38.0, 94.0, 46.0)),
+ ]
+ ),
+ drawing_lines=rules,
+ )
+
+ text = build_native_table_text(table_input)
+
+ assert text is not None
+ assert build_vector_candidates(table_input, text) == []
+
+
+def test_line_grid_prunes_inset_decorative_underlines() -> None:
+ """验证单元格内缩短下划线不会创建全表横轨。"""
+
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 120.0, 60.0),
+ page_size=(120.0, 60.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("Left top", (5.0, 5.0, 45.0, 14.0)),
+ ("Right top", (65.0, 5.0, 110.0, 14.0)),
+ ("Left bottom", (5.0, 35.0, 50.0, 44.0)),
+ ("Right bottom", (65.0, 35.0, 115.0, 44.0)),
+ ]
+ ),
+ drawing_lines=(
+ *_grid_rules(width=120.0),
+ NativeTableRule((5.0, 17.5, 55.0, 18.5), 1.0, "horizontal"),
+ NativeTableRule((5.0, 23.5, 20.0, 24.5), 1.0, "horizontal"),
+ NativeTableRule((5.0, 47.5, 55.0, 48.5), 1.0, "horizontal"),
+ ),
+ )
+
+ result = recover_native_pdf_table(table_input)
+ diagnostics = diagnose_native_pdf_table(table_input)
+
+ assert result is not None
+ assert (result.rows, result.cols) == (2, 2)
+ line_attempt = next(attempt for attempt in diagnostics["vector_attempts"] if attempt["evidence"] == "line_grid")
+ assert line_attempt["track_hypothesis"] == "supported"
+ assert len(line_attempt["removed_horizontal_tracks"]) == 3
+ assert len(line_attempt["track_hypotheses"]) == 2
+
+
+def test_line_grid_keeps_partial_separator_spanning_complete_columns() -> None:
+ """验证跨完整列带的局部横线保留,同时删除单元格内短下划线。"""
+
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 120.0, 60.0),
+ page_size=(120.0, 60.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("A", (10.0, 10.0, 14.0, 18.0)),
+ ("B", (50.0, 10.0, 54.0, 18.0)),
+ ("C", (90.0, 10.0, 94.0, 18.0)),
+ ("D", (50.0, 40.0, 54.0, 48.0)),
+ ("E", (90.0, 40.0, 94.0, 48.0)),
+ ]
+ ),
+ drawing_lines=(
+ NativeTableRule((0.0, 0.0, 120.0, 1.0), 1.0, "horizontal"),
+ NativeTableRule((40.0, 29.5, 120.0, 30.5), 1.0, "horizontal"),
+ NativeTableRule((0.0, 59.0, 120.0, 60.0), 1.0, "horizontal"),
+ NativeTableRule((45.0, 22.5, 58.0, 23.5), 1.0, "horizontal"),
+ NativeTableRule((0.0, 0.0, 1.0, 60.0), 1.0, "vertical"),
+ NativeTableRule((39.5, 0.0, 40.5, 60.0), 1.0, "vertical"),
+ NativeTableRule((79.5, 0.0, 80.5, 60.0), 1.0, "vertical"),
+ NativeTableRule((119.0, 0.0, 120.0, 60.0), 1.0, "vertical"),
+ ),
+ )
+
+ result = recover_native_pdf_table(table_input)
+ diagnostics = diagnose_native_pdf_table(table_input)
+
+ assert result is not None
+ assert (result.rows, result.cols) == (2, 3)
+ assert result.cells[0].rowspan == 2
+ line_attempt = next(attempt for attempt in diagnostics["vector_attempts"] if attempt["evidence"] == "line_grid")
+ assert line_attempt["track_hypothesis"] == "supported"
+ assert len(line_attempt["removed_horizontal_tracks"]) == 1
+
+
[email protected]("angle", [0, 90, 180, 270])
+def test_single_column_line_grid_supports_standard_rotations(angle: int) -> None:
+ """验证强线框单列表单在四种标准方向下保留文本和转义。"""
+
+ result = recover_native_pdf_table(_rotated_single_column_input(angle))
+
+ assert result is not None
+ assert result.source == "vector_grid"
+ assert (result.rows, result.cols) == (2, 1)
+ assert result.html == ("<table><tbody><tr><td>A&amp;B</td></tr><tr><td>Value A B</td></tr></tbody></table>")
+ assert "single_column_line_grid=true" in result.diagnostics
+
+
[email protected]("missing", ["right", "middle"])
+def test_single_column_line_grid_requires_complete_physical_frame(
+ missing: str,
+) -> None:
+ """验证缺少侧边或行分隔的单列区域不能进入 HTML。"""
+
+ rules = [
+ NativeTableRule((0.0, 0.0, 100.0, 1.0), 1.0, "horizontal"),
+ NativeTableRule((0.0, 29.5, 100.0, 30.5), 1.0, "horizontal"),
+ NativeTableRule((0.0, 59.0, 100.0, 60.0), 1.0, "horizontal"),
+ NativeTableRule((0.0, 0.0, 1.0, 60.0), 1.0, "vertical"),
+ NativeTableRule((99.0, 0.0, 100.0, 60.0), 1.0, "vertical"),
+ ]
+ if missing == "right":
+ rules.pop()
+ else:
+ rules.pop(1)
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 100.0, 60.0),
+ page_size=(100.0, 60.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("Header", (10.0, 10.0, 34.0, 18.0)),
+ ("Value", (10.0, 40.0, 30.0, 48.0)),
+ ]
+ ),
+ drawing_lines=tuple(rules),
+ )
+
+ assert recover_native_pdf_table(table_input) is None
+
+
+def test_line_grid_rejects_single_cell_frame() -> None:
+ """验证完整外框中的单个文本块不能作为一行一列表格采用。"""
+
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 100.0, 40.0),
+ page_size=(100.0, 40.0),
+ angle=0,
+ chars=_char_items([("Paragraph", (10.0, 10.0, 46.0, 18.0))]),
+ drawing_lines=(
+ NativeTableRule((0.0, 0.0, 100.0, 1.0), 1.0, "horizontal"),
+ NativeTableRule((0.0, 39.0, 100.0, 40.0), 1.0, "horizontal"),
+ NativeTableRule((0.0, 0.0, 1.0, 40.0), 1.0, "vertical"),
+ NativeTableRule((99.0, 0.0, 100.0, 40.0), 1.0, "vertical"),
+ ),
+ )
+
+ assert recover_native_pdf_table(table_input) is None
+
+
+def test_line_grid_collapses_duplicate_outer_y_track_in_multirow_table() -> None:
+ """验证纵线端点与底部描边形成的重复外缘不会制造幽灵行。"""
+
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 100.0, 60.0),
+ page_size=(100.0, 60.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("A", (10.0, 10.0, 14.0, 18.0)),
+ ("B", (60.0, 10.0, 64.0, 18.0)),
+ ("C", (10.0, 40.0, 14.0, 48.0)),
+ ("D", (60.0, 40.0, 64.0, 48.0)),
+ ]
+ ),
+ drawing_lines=(
+ NativeTableRule((0.0, 0.0, 100.0, 1.0), 1.0, "horizontal"),
+ NativeTableRule((0.0, 29.5, 100.0, 30.5), 1.0, "horizontal"),
+ NativeTableRule((0.0, 59.5, 100.0, 60.0), 1.0, "horizontal"),
+ NativeTableRule((0.0, 0.0, 1.0, 59.0), 1.0, "vertical"),
+ NativeTableRule((49.5, 0.0, 50.5, 59.0), 1.0, "vertical"),
+ NativeTableRule((99.0, 0.0, 100.0, 59.0), 1.0, "vertical"),
+ ),
+ )
+
+ result = recover_native_pdf_table(table_input)
+ diagnostics = diagnose_native_pdf_table(table_input)
+
+ assert result is not None
+ assert (result.rows, result.cols) == (2, 2)
+ line_attempt = next(attempt for attempt in diagnostics["vector_attempts"] if attempt["evidence"] == "line_grid")
+ assert line_attempt["outer_track_collapses"]["y"] == 1
+
+
+def test_line_grid_preserves_independent_nearby_outer_boundaries() -> None:
+ """验证两条各自有强物理线的近邻外缘不会被重复轨规则折叠。"""
+
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 100.0, 60.0),
+ page_size=(100.0, 60.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("A", (10.0, 10.0, 14.0, 18.0)),
+ ("B", (60.0, 10.0, 64.0, 18.0)),
+ ("C", (10.0, 35.0, 14.0, 43.0)),
+ ("D", (60.0, 35.0, 64.0, 43.0)),
+ ]
+ ),
+ drawing_lines=(
+ NativeTableRule((0.0, 0.0, 100.0, 1.0), 1.0, "horizontal"),
+ NativeTableRule((0.0, 29.5, 100.0, 30.5), 1.0, "horizontal"),
+ NativeTableRule((0.0, 53.5, 100.0, 54.5), 1.0, "horizontal"),
+ NativeTableRule((0.0, 59.0, 100.0, 60.0), 1.0, "horizontal"),
+ NativeTableRule((0.0, 0.0, 1.0, 60.0), 1.0, "vertical"),
+ NativeTableRule((49.5, 0.0, 50.5, 54.0), 1.0, "vertical"),
+ NativeTableRule((99.0, 0.0, 100.0, 60.0), 1.0, "vertical"),
+ ),
+ )
+
+ result = recover_native_pdf_table(table_input)
+ diagnostics = diagnose_native_pdf_table(table_input)
+ line_attempt = next(attempt for attempt in diagnostics["vector_attempts"] if attempt["evidence"] == "line_grid")
+ assert line_attempt["outer_track_collapses"]["y"] == 0
+ assert result is not None
+ assert result.source != "vector_grid"
+
+
+def test_line_grid_does_not_fold_distinct_short_rule_into_outer_border() -> None:
+ """验证外缘附近存在独立短物理线时保留原有 rowspan 拓扑。"""
+
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 400.0, 60.0),
+ page_size=(400.0, 60.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("A", (10.0, 10.0, 14.0, 18.0)),
+ ("B", (120.0, 10.0, 124.0, 18.0)),
+ ("C", (270.0, 10.0, 274.0, 18.0)),
+ ("D", (10.0, 40.0, 14.0, 48.0)),
+ ("E", (120.0, 40.0, 124.0, 48.0)),
+ ("F", (270.0, 40.0, 274.0, 48.0)),
+ ]
+ ),
+ drawing_lines=(
+ NativeTableRule((0.0, 0.0, 400.0, 1.0), 1.0, "horizontal"),
+ NativeTableRule((0.0, 29.5, 400.0, 30.5), 1.0, "horizontal"),
+ NativeTableRule((5.0, 53.5, 17.0, 54.5), 1.0, "horizontal"),
+ NativeTableRule((0.0, 59.0, 400.0, 60.0), 1.0, "horizontal"),
+ NativeTableRule((0.0, 0.0, 1.0, 60.0), 1.0, "vertical"),
+ NativeTableRule((99.5, 0.0, 100.5, 60.0), 1.0, "vertical"),
+ NativeTableRule((249.5, 0.0, 250.5, 60.0), 1.0, "vertical"),
+ NativeTableRule((399.0, 0.0, 400.0, 60.0), 1.0, "vertical"),
+ ),
+ )
+
+ result = recover_native_pdf_table(table_input)
+ diagnostics = diagnose_native_pdf_table(table_input)
+
+ assert result is not None
+ assert result.source == "vector_grid"
+ assert (result.rows, result.cols) == (3, 3)
+ assert all(cell.rowspan == 2 for cell in result.cells if cell.row == 1)
+ line_attempt = next(attempt for attempt in diagnostics["vector_attempts"] if attempt["evidence"] == "line_grid")
+ assert line_attempt["outer_track_collapses"]["y"] == 0
+
+
+def test_single_row_line_grid_recovers_clipped_outer_borders() -> None:
+ """验证 drawing halo 可恢复 bbox 外邻近边框且保留物理空列。"""
+
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 2.0, 120.0, 58.0),
+ page_size=(120.0, 60.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("A", (10.0, 10.0, 15.0, 18.0)),
+ ("C", (90.0, 38.0, 95.0, 46.0)),
+ ]
+ ),
+ drawing_lines=(
+ NativeTableRule((0.0, 0.5, 120.0, 1.0), 0.5, "horizontal"),
+ NativeTableRule((0.0, 59.0, 120.0, 59.5), 0.5, "horizontal"),
+ NativeTableRule((0.0, 1.0, 0.5, 59.0), 0.5, "vertical"),
+ NativeTableRule((39.75, 1.0, 40.25, 59.0), 0.5, "vertical"),
+ NativeTableRule((79.75, 1.0, 80.25, 59.0), 0.5, "vertical"),
+ NativeTableRule((119.5, 1.0, 120.0, 59.0), 0.5, "vertical"),
+ ),
+ )
+
+ result = recover_native_pdf_table(table_input)
+ diagnostics = diagnose_native_pdf_table(table_input)
+
+ assert result is not None
+ assert (result.rows, result.cols) == (1, 3)
+ assert result.html == ("<table><tbody><tr><td>A</td><td></td><td>C</td></tr></tbody></table>")
+ assert "single_row_line_grid=true" in result.diagnostics
+ line_attempt = next(attempt for attempt in diagnostics["vector_attempts"] if attempt["evidence"] == "line_grid")
+ assert line_attempt["evidence_halo"] > 0
+ assert line_attempt["single_row_evidence"]["verified"] is True
+
+
+def test_single_row_line_grid_rejects_missing_outer_border() -> None:
+ """验证单物理行缺少任一横向外框时继续主动回退。"""
+
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 120.0, 60.0),
+ page_size=(120.0, 60.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("A", (10.0, 10.0, 15.0, 18.0)),
+ ("B", (50.0, 10.0, 55.0, 18.0)),
+ ("C", (90.0, 10.0, 95.0, 18.0)),
+ ]
+ ),
+ drawing_lines=(
+ NativeTableRule((0.0, 0.0, 120.0, 1.0), 1.0, "horizontal"),
+ NativeTableRule((0.0, 0.0, 1.0, 60.0), 1.0, "vertical"),
+ NativeTableRule((39.5, 0.0, 40.5, 60.0), 1.0, "vertical"),
+ NativeTableRule((79.5, 0.0, 80.5, 60.0), 1.0, "vertical"),
+ NativeTableRule((119.0, 0.0, 120.0, 60.0), 1.0, "vertical"),
+ ),
+ )
+
+ assert recover_native_pdf_table(table_input) is None
+ diagnostics = diagnose_native_pdf_table(table_input)
+ assert diagnostics["first_rejection_gate"] == ("vector_single_row_physical_evidence")
+
+
[email protected]("angle", [0, 90, 180, 270])
+def test_single_row_line_grid_supports_standard_rotations(angle: int) -> None:
+ """验证强线框单物理行在四种标准旋转下保持同一拓扑。"""
+
+ result = recover_native_pdf_table(_rotated_single_row_input(angle))
+
+ assert result is not None
+ assert (result.rows, result.cols) == (1, 3)
+ assert [cell.content for cell in result.cells] == ["A", "B", "C"]
+
+
+def test_vector_cell_preserves_explicit_small_gap_space() -> None:
+ """验证 PDF 字符流显式空格在几何间距很小时仍不会丢失。"""
+
+ chars = (
+ {"char": "A", "bbox": (10.0, 10.0, 14.0, 18.0), "char_idx": 0},
+ {"char": " ", "bbox": (14.0, 10.0, 14.5, 18.0), "char_idx": 1},
+ {"char": "B", "bbox": (14.5, 10.0, 18.5, 18.0), "char_idx": 2},
+ {"char": "X", "bbox": (60.0, 10.0, 64.0, 18.0), "char_idx": 3},
+ {"char": "C", "bbox": (10.0, 40.0, 14.0, 48.0), "char_idx": 4},
+ {"char": "D", "bbox": (60.0, 40.0, 64.0, 48.0), "char_idx": 5},
+ )
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 100.0, 60.0),
+ page_size=(100.0, 60.0),
+ angle=0,
+ chars=chars, # type: ignore[arg-type]
+ drawing_lines=_grid_rules(),
+ )
+
+ result = recover_native_pdf_table(table_input)
+
+ assert result is not None
+ assert "<td>A B</td>" in result.html
+
+
+def test_reportlab_pdf_primitives_recover_expected_html() -> None:
+ """验证真实 ReportLab PDF 的字符与 drawing 可端到端恢复结构。"""
+
+ with PDFDocument(_build_reportlab_table_pdf()) as document:
+ page = document[0]
+ result = recover_native_pdf_table(
+ NativeTableInput(
+ table_bbox=(20.0, 40.0, 180.0, 160.0),
+ page_size=page.size,
+ angle=0,
+ chars=tuple(page.get_chars()),
+ drawing_lines=coerce_native_table_rules(page.get_drawing_lines()),
+ rectangles=coerce_native_table_rectangles(page.get_path_infos()),
+ )
+ )
+
+ assert result is not None
+ assert result.source == "vector_grid"
+ assert result.html == ("<table><tbody><tr><td>A</td><td>B</td></tr><tr><td>C</td><td>D</td></tr></tbody></table>")
+
+
+ ("vertical_range", "horizontal_range", "expected_attribute"),
+ [
+ ((30.0, 60.0), (0.0, 100.0), 'colspan="2"'),
+ ((0.0, 60.0), (50.0, 100.0), 'rowspan="2"'),
+ ],
+)
+def test_vector_grid_recovers_rectangular_spans(
+ vertical_range: tuple[float, float],
+ horizontal_range: tuple[float, float],
+ expected_attribute: str,
+) -> None:
+ """验证内部隔断缺失只生成矩形横向或纵向合并格。"""
+
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 100.0, 60.0),
+ page_size=(100.0, 60.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("A", (10.0, 10.0, 15.0, 18.0)),
+ ("B", (60.0, 10.0, 65.0, 18.0)),
+ ("C", (10.0, 40.0, 15.0, 48.0)),
+ ("D", (60.0, 40.0, 65.0, 48.0)),
+ ]
+ ),
+ drawing_lines=_grid_rules(
+ internal_vertical=vertical_range,
+ internal_horizontal=horizontal_range,
+ ),
+ )
+
+ result = recover_native_pdf_table(table_input)
+
+ assert result is not None
+ assert expected_attribute in result.html
+
+
+def test_vector_grid_rejects_non_rectangular_merge_component() -> None:
+ """验证横纵缺边形成 L 形连通域时拒绝矢量候选。"""
+
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 100.0, 60.0),
+ page_size=(100.0, 60.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("A", (10.0, 10.0, 15.0, 18.0)),
+ ("B", (60.0, 10.0, 65.0, 18.0)),
+ ("C", (10.0, 40.0, 15.0, 48.0)),
+ ("D", (60.0, 40.0, 65.0, 48.0)),
+ ]
+ ),
+ drawing_lines=_grid_rules(
+ internal_vertical=(30.0, 60.0),
+ internal_horizontal=(50.0, 100.0),
+ ),
+ )
+ text = build_native_table_text(table_input)
+
+ assert text is not None
+ assert build_vector_candidates(table_input, text) == []
+
+
+def test_vector_cell_concatenates_multiple_visual_lines() -> None:
+ """验证同一逻辑单元格中的多行文本直接拼接且不写入 HTML 换行。"""
+
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 100.0, 60.0),
+ page_size=(100.0, 60.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("A", (10.0, 6.0, 15.0, 12.0)),
+ ("B", (10.0, 18.0, 15.0, 24.0)),
+ ("X", (60.0, 10.0, 65.0, 18.0)),
+ ("C", (10.0, 40.0, 15.0, 48.0)),
+ ("D", (60.0, 40.0, 65.0, 48.0)),
+ ]
+ ),
+ drawing_lines=_grid_rules(),
+ )
+
+ result = recover_native_pdf_table(table_input)
+
+ assert result is not None
+ assert "<td>AB</td>" in result.html
+ assert "<br>" not in result.html
+
+
[email protected]("angle", [0, 90, 180, 270])
+def test_text_grid_supports_standard_table_rotations(angle: int) -> None:
+ """验证三列无线表在四个标准方向下恢复相同结构。"""
+
+ result = recover_native_pdf_table(
+ _aligned_text_input(
+ [
+ ["A", "B", "C"],
+ ["1", "2", "3"],
+ ["4", "5", "6"],
+ ],
+ angle=angle,
+ )
+ )
+
+ assert result is not None
+ assert result.source == "text_grid"
+ assert (result.rows, result.cols) == (3, 3)
+ assert "<tr><td>4</td><td>5</td><td>6</td></tr>" in result.html
+
+
+def test_text_grid_preserves_empty_cells() -> None:
+ """验证缺少文本的叶子列保留空 td,且不会被推断为合并格。"""
+
+ result = recover_native_pdf_table(
+ _aligned_text_input(
+ [
+ ["A", "B", "C"],
+ ["1", None, "3"],
+ ["4", "5", "6"],
+ ]
+ )
+ )
+
+ assert result is not None
+ assert "<tr><td>1</td><td></td><td>3</td></tr>" in result.html
+ assert "rowspan" not in result.html
+ assert "colspan" not in result.html
+
+
+def test_text_grid_groups_tight_subset_continuation_without_break() -> None:
+ """验证无线表紧邻且不引入新列的续行并入同一逻辑行且直接拼接。"""
+
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 120.0, 75.0),
+ page_size=(120.0, 75.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("A1", (8.0, 5.0, 16.0, 13.0)),
+ ("B1", (48.0, 5.0, 56.0, 13.0)),
+ ("C1", (88.0, 5.0, 96.0, 13.0)),
+ ("A2", (8.0, 14.0, 16.0, 22.0)),
+ ("1", (8.0, 36.0, 12.0, 44.0)),
+ ("2", (48.0, 36.0, 52.0, 44.0)),
+ ("3", (88.0, 36.0, 92.0, 44.0)),
+ ("4", (8.0, 60.0, 12.0, 68.0)),
+ ("5", (48.0, 60.0, 52.0, 68.0)),
+ ("6", (88.0, 60.0, 92.0, 68.0)),
+ ]
+ ),
+ )
+
+ result = recover_native_pdf_table(table_input)
+
+ assert result is not None
+ assert (result.rows, result.cols) == (3, 3)
+ assert "<tr><td>A1A2</td><td>B1</td><td>C1</td></tr>" in result.html
+
+
+def test_text_grid_accepts_right_aligned_numeric_columns() -> None:
+ """验证数字宽度变化但右缘稳定时仍能恢复同一列结构。"""
+
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 110.0, 70.0),
+ page_size=(110.0, 70.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("Name", (10.0, 5.0, 26.0, 13.0)),
+ ("Count", (40.0, 5.0, 60.0, 13.0)),
+ ("Rate", (84.0, 5.0, 100.0, 13.0)),
+ ("A", (10.0, 28.0, 14.0, 36.0)),
+ ("1", (56.0, 28.0, 60.0, 36.0)),
+ ("10", (92.0, 28.0, 100.0, 36.0)),
+ ("B", (10.0, 51.0, 14.0, 59.0)),
+ ("1000", (44.0, 51.0, 60.0, 59.0)),
+ ("2", (96.0, 51.0, 100.0, 59.0)),
+ ]
+ ),
+ )
+
+ result = recover_native_pdf_table(table_input)
+
+ assert result is not None
+ assert (result.rows, result.cols) == (3, 3)
+ assert "<tr><td>B</td><td>1000</td><td>2</td></tr>" in result.html
+
+
+def test_text_grid_recovers_conservative_multicolumn_header() -> None:
+ """验证前导单项文本真实横跨叶子列时生成 colspan。"""
+
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 100.0, 70.0),
+ page_size=(100.0, 70.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("ABCDEFGHIJKLMNOPQR", (5.0, 5.0, 95.0, 13.0)),
+ ("A", (10.0, 30.0, 14.0, 38.0)),
+ ("B", (45.0, 30.0, 49.0, 38.0)),
+ ("C", (80.0, 30.0, 84.0, 38.0)),
+ ("1", (10.0, 52.0, 14.0, 60.0)),
+ ("2", (45.0, 52.0, 49.0, 60.0)),
+ ("3", (80.0, 52.0, 84.0, 60.0)),
+ ]
+ ),
+ )
+
+ result = recover_native_pdf_table(table_input)
+
+ assert result is not None
+ assert '<td colspan="3">ABCDEFGHIJKLMNOPQR</td>' in result.html
+
+
+def test_key_value_candidate_handles_two_stable_columns() -> None:
+ """验证两列字段值表走独立 key-value 候选。"""
+
+ result = recover_native_pdf_table(
+ _aligned_text_input(
+ [
+ ["Name", "Alice"],
+ ["Age", "30"],
+ ["City", "Paris"],
+ ]
+ )
+ )
+
+ assert result is not None
+ assert result.source == "key_value"
+ assert "<td>Name</td><td>Alice</td>" in result.html
+
+
+def test_text_grid_abstains_for_prose_without_repeated_columns() -> None:
+ """验证已知 bbox 内只有连续正文行时仍主动放弃结构化。"""
+
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 120.0, 70.0),
+ page_size=(120.0, 70.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("This is a complete sentence.", (5.0, 5.0, 110.0, 13.0)),
+ ("It continues as ordinary prose.", (5.0, 28.0, 112.0, 36.0)),
+ ("No stable columns are present.", (5.0, 51.0, 108.0, 59.0)),
+ ]
+ ),
+ )
+
+ assert recover_native_pdf_table(table_input) is None
+
+
[email protected]("evidence", ["booktabs", "stripes"])
+def test_sparse_candidate_uses_rules_or_row_stripes(evidence: str) -> None:
+ """验证三线规则和重复行底纹均可提升同拓扑少线候选。"""
+
+ rules: tuple[NativeTableRule, ...] = ()
+ rectangles: tuple[NativeTableRectangle, ...] = ()
+ if evidence == "booktabs":
+ rules = (
+ NativeTableRule((0.0, 5.0, 120.0, 6.0), 1.0, "horizontal"),
+ NativeTableRule((0.0, 35.0, 120.0, 36.0), 1.0, "horizontal"),
+ NativeTableRule((0.0, 84.0, 120.0, 85.0), 1.0, "horizontal"),
+ )
+ else:
+ rectangles = (
+ NativeTableRectangle((0.0, 8.0, 120.0, 18.0), 5, True, False),
+ NativeTableRectangle((0.0, 38.0, 120.0, 48.0), 5, True, False),
+ NativeTableRectangle((0.0, 68.0, 120.0, 78.0), 5, True, False),
+ )
+ result = recover_native_pdf_table(
+ _aligned_text_input(
+ [
+ ["A", "B", "C"],
+ ["1", "2", "3"],
+ ["4", "5", "6"],
+ ],
+ rules=rules,
+ rectangles=rectangles,
+ )
+ )
+
+ assert result is not None
+ assert result.source == "sparse_grid"
+
+
+def test_candidate_conflict_with_close_scores_abstains() -> None:
+ """验证近分异构候选无法建立明确优势时主动放弃。"""
+
+ assert (
+ _select_candidate(
+ [
+ _candidate(source="vector_grid", rows=2, cols=2, score=0.94),
+ _candidate(source="text_grid", rows=3, cols=3, score=0.92),
+ ]
+ )
+ is None
+ )
+
+
+def test_verified_line_grid_wins_conflicting_text_topology() -> None:
+ """验证无歧义 drawing 网格以独立物理证据胜出异构文本候选。"""
+
+ line = _candidate(
+ source="vector_grid",
+ rows=2,
+ cols=4,
+ score=1.0,
+ issues=(
+ "evidence=line_grid",
+ "ambiguous_separator_ratio=0.0000",
+ ),
+ )
+ text = _candidate(source="text_grid", rows=3, cols=4, score=1.0)
+
+ assert _select_candidate([line, text]) is line
+
+
+def test_text_candidate_removes_significantly_undercounted_vector() -> None:
+ """验证稳定文本候选显著多出行列时剔除欠分割矢量候选。"""
+
+ vector = _candidate(source="vector_grid", rows=2, cols=2, score=0.96)
+ text = _candidate(source="text_grid", rows=3, cols=3, score=0.93)
+
+ assert _remove_undercounted_vector_candidates([vector, text]) == [text]
+
+
+def test_verified_line_grid_is_not_removed_by_text_undercount() -> None:
+ """验证无歧义强物理网格不会被多 baseline 文本候选误判欠分割。"""
+
+ vector = _candidate(
+ source="vector_grid",
+ rows=2,
+ cols=2,
+ score=0.96,
+ issues=(
+ "evidence=line_grid",
+ "ambiguous_separator_ratio=0.0000",
+ ),
+ )
+ text = _candidate(source="text_grid", rows=4, cols=3, score=0.93)
+
+ assert _remove_undercounted_vector_candidates([vector, text]) == [vector, text]
+
+
+def test_primitive_limit_falls_back_before_candidate_generation() -> None:
+ """验证单表原语超过保护上限时直接主动放弃。"""
+
+ base = _aligned_text_input(
+ [
+ ["A", "B", "C"],
+ ["1", "2", "3"],
+ ["4", "5", "6"],
+ ]
+ )
+ rules = tuple(NativeTableRule((0.0, 1.0, 120.0, 2.0), 1.0, "horizontal") for _ in range(MAX_PRIMITIVES_PER_TABLE + 1))
+ table_input = NativeTableInput(
+ table_bbox=base.table_bbox,
+ page_size=base.page_size,
+ angle=base.angle,
+ chars=base.chars,
+ drawing_lines=rules,
+ )
+
+ assert recover_native_pdf_table(table_input) is None
+ diagnostics = diagnose_native_pdf_table(table_input)
+ assert diagnostics["first_rejection_gate"] == "primitive_limit"
+ assert diagnostics["generated_candidates"] == []
+
+
+def test_diagnostics_records_tracks_components_and_adoption() -> None:
+ """验证调试入口记录轨道、分项可靠度和最终采用状态。"""
+
+ table_input = NativeTableInput(
+ table_bbox=(0.0, 0.0, 100.0, 60.0),
+ page_size=(100.0, 60.0),
+ angle=0,
+ chars=_char_items(
+ [
+ ("A", (10.0, 10.0, 15.0, 18.0)),
+ ("B", (60.0, 10.0, 65.0, 18.0)),
+ ("C", (10.0, 40.0, 15.0, 48.0)),
+ ("D", (60.0, 40.0, 65.0, 48.0)),
+ ]
+ ),
+ drawing_lines=_grid_rules(),
+ )
+
+ diagnostics = diagnose_native_pdf_table(table_input)
+
+ assert diagnostics["first_rejection_gate"] is None
+ assert diagnostics["adopted"]["tracks"] == {"x": 3, "y": 3}
+ assert diagnostics["adopted"]["score_components"]["text_capture"] == 1.0
+ assert diagnostics["counterfactual_best"]["source"] == "vector_grid"
+ line_attempt = next(attempt for attempt in diagnostics["vector_attempts"] if attempt["evidence"] == "line_grid")
+ assert line_attempt["first_rejection_gate"] is None
+ assert line_attempt["grid"] == {"rows": 2, "cols": 2}
diff --git a/tests/unittest/test_native_pdf_table_manifest.py b/tests/unittest/test_native_pdf_table_manifest.py
new file mode 100644
index 00000000..71ff6dad
--- /dev/null
+++ b/tests/unittest/test_native_pdf_table_manifest.py
@@ -0,0 +1,106 @@
+# Copyright (c) Opendatalab. All rights reserved.
+"""验证仓库内 Native PDF Table 真实语料、隐私和结构发布门。"""
+
+from __future__ import annotations
+
+import json
+import hashlib
+import subprocess
+import sys
+from pathlib import Path
+
+from pypdf import PdfReader
+
+
+_PROJECT_ROOT = Path(__file__).parents[2]
+_FIXTURE_ROOT = Path(__file__).parent / "pdfs" / "native_pdf_tables"
+_EVALUATOR = _PROJECT_ROOT / "tests" / "fixtures" / "evaluate_native_pdf_table_manifest.py"
+_EXPECTED_PAGE_COUNTS = {
+ "annual_report_fundraising_projects_table.pdf": 2,
+ "annual_report_management_roles_table.pdf": 2,
+ "annual_report_research_projects_table.pdf": 2,
+ "conference_schedule_tables.pdf": 12,
+ "engineering_process_restrictions_table.pdf": 9,
+ "fund_asset_and_transaction_tables.pdf": 2,
+ "fund_manager_profile_table.pdf": 2,
+ "manufacturing_facilities_cross_page_table.pdf": 2,
+ "pollutant_discharge_tables.pdf": 89,
+ "procurement_contract_tables.pdf": 2,
+ "procurement_document_blank_page_tables.pdf": 4,
+ "quarterly_report_financial_tables.pdf": 2,
+}
+_SENSITIVE_PROBE_HASHES = (
+ (14, "f467375e9c732abd34da5916ef67d09601fe5a160fc07e34eae45b40b92a66fd"),
+ (12, "14627c288df62a412eca1a27ed52b6126bf2958b4be4a67694dd7d1144937f11"),
+ (10, "9b2e4ae1fe4b64def12ddb3e1096c542a47a8278c789d321641dbef69e9711cd"),
+ (18, "df3f9bd04eb98a918d39eb50ff84d22d16296aa39297e2b6c93bc27d5ebd301f"),
+ (2, "a03f26ca7f4771eecaf858e1dced39d5213c3423084bafdb62d1086c382ae906"),
+ (3, "99bc11448af2388b7cdba8f712eab541b868931286bce3162703de572b27d97f"),
+ (11, "ed0491aea67e74b66b983ee86ee32f067693f7603812b66127fd8e4be79ebbdc"),
+)
+
+
+def _contains_sensitive_probe_hash(text: str) -> bool:
+ """使用不可逆摘要检查已知敏感片段,避免把原文写入仓库。"""
+
+ for length, expected_digest in _SENSITIVE_PROBE_HASHES:
+ if any(
+ hashlib.sha256(text[start : start + length].encode()).hexdigest() == expected_digest
+ for start in range(max(0, len(text) - length + 1))
+ ):
+ return True
+ return False
+
+
+def test_repository_native_table_manifest_matches_all_fixtures() -> None:
+ """验证仓库内 133 表真值及六个 Flash 精确目标全部匹配。"""
+
+ completed = subprocess.run(
+ [
+ sys.executable,
+ str(_EVALUATOR),
+ "--skip-performance-gate",
+ ],
+ cwd=_PROJECT_ROOT,
+ check=False,
+ capture_output=True,
+ text=True,
+ )
+ assert completed.returncode == 0, completed.stdout + completed.stderr
+ payload = json.loads(completed.stdout)
+ assert payload["summary"] | {
+ "p95_milliseconds": 0.0,
+ } == {
+ "accuracy_scope": "targeted_only",
+ "tables": 133,
+ "html": 133,
+ "coverage": 1.0,
+ "target_tables": 41,
+ "target_html": 41,
+ "target_mismatches": 0,
+ "target_precision": 1.0,
+ "regression_mismatches": 0,
+ "flash_targets": 6,
+ "flash_target_html": 6,
+ "flash_target_mismatches": 0,
+ "p95_milliseconds": 0.0,
+ }
+
+
+def test_repository_native_table_fixtures_are_sanitized() -> None:
+ """验证文件清单、页数、文档信息和污染物敏感字段均符合提交边界。"""
+
+ fixture_paths = sorted(_FIXTURE_ROOT.glob("*.pdf"))
+ assert {path.name for path in fixture_paths} == set(_EXPECTED_PAGE_COUNTS)
+ for path in fixture_paths:
+ reader = PdfReader(path)
+ assert len(reader.pages) == _EXPECTED_PAGE_COUNTS[path.name]
+ assert not reader.metadata
+ assert reader.xmp_metadata is None
+ assert reader.trailer.get("/Info") is None
+ assert "/Metadata" not in reader.root_object
+ assert all("/Metadata" not in page for page in reader.pages)
+
+ pollutant_reader = PdfReader(_FIXTURE_ROOT / "pollutant_discharge_tables.pdf")
+ visible_text = "".join("".join((page.extract_text() or "").split()) for page in pollutant_reader.pages)
+ assert not _contains_sensitive_probe_hash(visible_text)
diff --git a/tests/unittest/test_native_pdf_table_pipeline.py b/tests/unittest/test_native_pdf_table_pipeline.py
new file mode 100644
index 00000000..49b4e518
--- /dev/null
+++ b/tests/unittest/test_native_pdf_table_pipeline.py
@@ -0,0 +1,210 @@
+# Copyright (c) Opendatalab. All rights reserved.
+"""验证 Native PDF 表格结构恢复在 Flash/Low pipeline 中的采用与回退。"""
+
+from __future__ import annotations
+
+from types import SimpleNamespace
+from unittest.mock import MagicMock
+
+import pytest
+from PIL import Image
+
+from mineru.backend.analysis.pdf import tables as low_tables
+from mineru.model.flash.native_pdf import models as flash_models
+from mineru.model.flash.native_pdf import tables as flash_tables
+from mineru.types import BlockType
+from mineru.utils.native_pdf_table import NativeTableResult
+
+
+def _native_result(html: str) -> NativeTableResult:
+ """构造 pipeline 采用分支需要的最小原生结构结果。"""
+
+ return NativeTableResult(
+ html=html,
+ rows=2,
+ cols=2,
+ cells=(),
+ source="vector_grid",
+ confidence=1.0,
+ )
+
+
+def test_flash_materialization_prefers_native_html_and_keeps_claims(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ """验证 Flash 只替换表体 content,不改变候选认领语义。"""
+
+ source = flash_models._PageSource(
+ page_size=(100.0, 100.0),
+ lines=[
+ flash_models._LineItem(
+ text="A B",
+ bbox=(10.0, 20.0, 80.0, 30.0),
+ angle=0,
+ source_index=7,
+ effective_height=10.0,
+ )
+ ],
+ chars=[],
+ drawing_lines=[],
+ )
+ candidate = flash_models._TableCandidate(
+ bbox=(0.0, 10.0, 90.0, 40.0),
+ local_bbox=(0.0, 10.0, 90.0, 40.0),
+ angle=0,
+ score=1.0,
+ core_bbox=(0.0, 10.0, 90.0, 40.0),
+ line_indices={7},
+ )
+ html = "<table><tbody><tr><td>A</td><td>B</td></tr></tbody></table>"
+ projection = MagicMock(return_value="fallback")
+ monkeypatch.setattr(flash_tables, "_recover_native_table_html", MagicMock(return_value=html))
+ monkeypatch.setattr(flash_tables, "project_pdf_table_text", projection)
+
+ blocks, annotations, claimed = flash_tables._materialize_table_blocks(
+ source,
+ [candidate],
+ )
+
+ assert annotations == []
+ assert claimed == {7}
+ assert blocks[0]["content"] == html
+ assert "cell_merge" not in blocks[0]
+ projection.assert_not_called()
+
+
+def test_low_txt_prefers_native_html_and_caches_page_primitives(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ """验证 Low TXT 采用原生 HTML,并按页只读取一次字符、drawing 和 Path。"""
+
+ html = "<table><tbody><tr><td>A</td><td>B</td></tr></tbody></table>"
+ recover = MagicMock(return_value=_native_result(html))
+ projection = MagicMock(return_value="fallback")
+ monkeypatch.setattr(low_tables, "recover_native_pdf_table", recover)
+ monkeypatch.setattr(low_tables, "project_pdf_table_text", projection)
+ pdf_page = MagicMock()
+ pdf_page.size = (100.0, 100.0)
+ pdf_page.rotation = 0
+ pdf_page.get_chars.return_value = []
+ pdf_page.get_drawing_lines.return_value = []
+ pdf_page.get_path_infos.return_value = []
+ model_list = [
+ [
+ {"type": BlockType.TABLE, "bbox": [0.1, 0.1, 0.9, 0.9], "angle": 0},
+ {"type": BlockType.TABLE, "bbox": [0.2, 0.2, 0.8, 0.8], "angle": 0},
+ ]
+ ]
+ image = Image.new("RGB", (100, 100), "white")
+ try:
+ low_tables._fill_low_table_contents(
+ [{"img_pil": image}],
+ [pdf_page],
+ model_list,
+ "txt",
+ MagicMock(),
+ )
+ finally:
+ image.close()
+
+ assert [block["content"] for block in model_list[0]] == [html, html]
+ assert all("cell_merge" not in block for block in model_list[0])
+ assert recover.call_count == 2
+ projection.assert_not_called()
+ pdf_page.get_chars.assert_called_once_with()
+ pdf_page.get_drawing_lines.assert_called_once_with()
+ pdf_page.get_path_infos.assert_called_once_with()
+
+
+def test_low_txt_rejection_keeps_existing_projection(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ """验证 Low TXT 原生候选主动放弃后仍逐字采用旧空间投影。"""
+
+ monkeypatch.setattr(low_tables, "recover_native_pdf_table", MagicMock(return_value=None))
+ projection = MagicMock(return_value="A B")
+ monkeypatch.setattr(low_tables, "project_pdf_table_text", projection)
+ pdf_page = MagicMock()
+ pdf_page.size = (100.0, 100.0)
+ pdf_page.rotation = 0
+ pdf_page.get_chars.return_value = []
+ pdf_page.get_drawing_lines.return_value = []
+ pdf_page.get_path_infos.return_value = []
+ model_list = [[{"type": BlockType.TABLE, "bbox": [0.1, 0.1, 0.9, 0.9]}]]
+ image = Image.new("RGB", (100, 100), "white")
+ try:
+ low_tables._fill_low_table_contents(
+ [{"img_pil": image}],
+ [pdf_page],
+ model_list,
+ "txt",
+ MagicMock(),
+ )
+ finally:
+ image.close()
+
+ assert model_list[0][0]["content"] == "A B"
+ projection.assert_called_once()
+
+
+def test_low_ocr_never_invokes_native_structure_recovery(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ """验证 Low OCR 保持现有 OCR 空间投影路径且不调用原生结构器。"""
+
+ recover = MagicMock(side_effect=AssertionError("native recovery must not run"))
+ monkeypatch.setattr(low_tables, "recover_native_pdf_table", recover)
+ monkeypatch.setattr(low_tables, "run_ocr_inference", MagicMock(return_value=[[]]))
+ monkeypatch.setattr(low_tables, "project_ocr_table_text", MagicMock(return_value="OCR TABLE"))
+ context = MagicMock()
+ context.get_ocr_model.return_value = SimpleNamespace(ocr=object())
+ model_list = [[{"type": BlockType.TABLE, "bbox": [0.1, 0.1, 0.9, 0.9]}]]
+ image = Image.new("RGB", (100, 100), "white")
+ try:
+ low_tables._fill_low_table_contents(
+ [{"img_pil": image}],
+ [MagicMock()],
+ model_list,
+ "ocr",
+ context,
+ )
+ finally:
+ image.close()
+
+ recover.assert_not_called()
+ assert model_list[0][0]["content"] == "OCR TABLE"
+
+
+def test_low_txt_compensates_pdf_page_dictionary_rotation(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ """验证 Low 原生结构器使用视觉角度而不改变表块原始角度字段。"""
+
+ recover = MagicMock(return_value=_native_result("<table></table>"))
+ monkeypatch.setattr(low_tables, "recover_native_pdf_table", recover)
+ pdf_page = MagicMock()
+ pdf_page.size = (100.0, 80.0)
+ pdf_page.rotation = 90
+ pdf_page.get_chars.return_value = []
+ pdf_page.get_drawing_lines.return_value = []
+ pdf_page.get_path_infos.return_value = []
+ table_block = {
+ "type": BlockType.TABLE,
+ "bbox": [0.1, 0.1, 0.9, 0.9],
+ "angle": 270,
+ }
+ image = Image.new("RGB", (100, 80), "white")
+ try:
+ low_tables._fill_low_table_contents(
+ [{"img_pil": image}],
+ [pdf_page],
+ [[table_block]],
+ "txt",
+ MagicMock(),
+ )
+ finally:
+ image.close()
+
+ native_input = recover.call_args.args[0]
+ assert native_input.angle == 0
+ assert table_block["angle"] == 270
diff --git a/tests/unittest/test_pdf_document.py b/tests/unittest/test_pdf_document.py
index 4d6a220f..d2438c94 100644
--- a/tests/unittest/test_pdf_document.py
+++ b/tests/unittest/test_pdf_document.py
@@ -2,6 +2,7 @@ from __future__ import annotations
from io import BytesIO
from typing import Any
+from unittest.mock import MagicMock
import pytest
from pypdf import PdfReader, PdfWriter
@@ -22,6 +23,17 @@ from reportlab.pdfgen.canvas import Canvas
from mineru.utils import pdf_document
+def test_pdf_page_exposes_path_infos_without_raw_pdfium_access() -> None:
+ """验证 PDFPage 只读代理当前页 Path 摘要并保留页索引。"""
+
+ document = MagicMock()
+ expected = [MagicMock()]
+ document.get_page_path_infos.return_value = expected
+
+ assert pdf_document.PDFPage(document, 3).get_path_infos() is expected
+ document.get_page_path_infos.assert_called_once_with(3)
+
+
def _build_drawing_pdf() -> bytes:
"""构造包含描边、填充细矩形、相邻线段、Form 矩阵和斜线的测试 PDF。"""
output = BytesIO()