mirror of
https://github.com/lllin000/PaperForge.git
synced 2026-07-22 06:50:53 +00:00
test(ocr): add portable vnext real-paper comparison harness
This commit is contained in:
parent
cba3f34a43
commit
6a332e6b49
3 changed files with 692 additions and 0 deletions
|
|
@ -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()]
|
||||
|
|
|
|||
670
tests/fixtures/ocr_vnext_real_papers/2HEUD5P9/blocks.structured.jsonl
vendored
Normal file
670
tests/fixtures/ocr_vnext_real_papers/2HEUD5P9/blocks.structured.jsonl
vendored
Normal file
File diff suppressed because one or more lines are too long
14
tests/test_ocr_figure_vnext_real_papers.py
Normal file
14
tests/test_ocr_figure_vnext_real_papers.py
Normal 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
|
||||
Loading…
Reference in a new issue