test(ocr): add portable vnext real-paper comparison harness

This commit is contained in:
LLLin000 2026-07-03 12:47:39 +08:00
parent cba3f34a43
commit 6a332e6b49
3 changed files with 692 additions and 0 deletions

View file

@ -31,6 +31,14 @@ def compare_inventories(legacy: dict[str, object], vnext: dict[str, object]) ->
),
}
def compare_blocks_file(blocks_path: Path) -> dict[str, object]:
blocks = [json.loads(line) for line in blocks_path.read_text(encoding="utf-8").splitlines() if line.strip()]
legacy = build_figure_inventory_legacy(blocks)
vnext = build_figure_inventory_vnext(blocks)
diff = compare_inventories(legacy, vnext)
diff["paper"] = blocks_path.parent.name
return diff
def main(blocks_path: str) -> int:
blocks = [json.loads(line) for line in Path(blocks_path).read_text(encoding="utf-8").splitlines() if line.strip()]

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,14 @@
from pathlib import Path
from scripts.dev.compare_figure_inventory_legacy_vs_vnext import compare_blocks_file
def test_real_paper_same_page_milestone_reports_diff_shape():
blocks_path = Path("tests/fixtures/ocr_vnext_real_papers/2HEUD5P9/blocks.structured.jsonl")
diff = compare_blocks_file(blocks_path)
assert diff["paper"] == "2HEUD5P9"
assert "legacy_matched_count" in diff
assert "vnext_matched_count" in diff
assert "legacy_consumed_block_ids" in diff
assert "vnext_consumed_block_ids" in diff