mirror of
https://github.com/lllin000/PaperForge.git
synced 2026-07-22 06:50:53 +00:00
feat(ocr): wire vnext special fallback passes into orchestrator
This commit is contained in:
parent
364094e4d9
commit
c975beb6f2
3 changed files with 211 additions and 2 deletions
|
|
@ -2982,21 +2982,30 @@ def build_figure_inventory(structured_blocks: list[dict], page_width: float = 12
|
|||
return build_figure_inventory_legacy(structured_blocks, page_width, page_pdf_lines_by_page)
|
||||
|
||||
def build_figure_inventory_vnext(structured_blocks: list[dict], page_width: float = 1200) -> dict[str, Any]:
|
||||
from .ocr_figure_vnext_bundle_pass import LegendBundlePass
|
||||
from .ocr_figure_vnext_corpus import FigureCandidateIndex, FigureCorpus
|
||||
|
||||
from .ocr_figure_vnext_locator_pass import LocatorBridgePass
|
||||
from .ocr_figure_vnext_passes import (
|
||||
CrossPageReservationPass,
|
||||
CrossPageSettlementPass,
|
||||
PrimarySamePagePass,
|
||||
_resource_page,
|
||||
)
|
||||
from .ocr_figure_vnext_sidecar_pass import SidecarPass
|
||||
from .ocr_figure_vnext_state import FigurePipelineState, OwnershipLedger
|
||||
|
||||
corpus = FigureCorpus.from_blocks(structured_blocks, page_width=page_width)
|
||||
candidate_index = FigureCandidateIndex.from_corpus(corpus)
|
||||
state = FigurePipelineState(corpus=corpus, candidate_index=candidate_index, ledger=OwnershipLedger())
|
||||
reports = []
|
||||
for pass_cls in (PrimarySamePagePass, CrossPageReservationPass, CrossPageSettlementPass):
|
||||
for pass_cls in (
|
||||
PrimarySamePagePass,
|
||||
SidecarPass,
|
||||
LocatorBridgePass,
|
||||
CrossPageReservationPass,
|
||||
CrossPageSettlementPass,
|
||||
LegendBundlePass,
|
||||
):
|
||||
reports.append(pass_cls().run(state))
|
||||
matched_ids = {str(m.get("legend_block_id", "")) for m in state.matches}
|
||||
|
||||
|
|
|
|||
189
tests/fixtures/ocr_vnext_real_papers/YGH7VEX6/blocks.structured.jsonl
vendored
Normal file
189
tests/fixtures/ocr_vnext_real_papers/YGH7VEX6/blocks.structured.jsonl
vendored
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -23,3 +23,14 @@ def test_real_paper_cross_page_milestone_reports_diff_shape():
|
|||
assert "vnext_matched_count" in diff
|
||||
assert "legacy_consumed_block_ids" in diff
|
||||
assert "vnext_consumed_block_ids" in diff
|
||||
|
||||
|
||||
def test_real_paper_special_fallbacks_reports_diff_shape():
|
||||
blocks_path = Path("tests/fixtures/ocr_vnext_real_papers/YGH7VEX6/blocks.structured.jsonl")
|
||||
diff = compare_blocks_file(blocks_path)
|
||||
|
||||
assert diff["paper"] == "YGH7VEX6"
|
||||
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