mirror of
https://github.com/lllin000/PaperForge.git
synced 2026-07-22 06:50:53 +00:00
feat: wire pdf text fallback into OCR postprocessing pipeline
This commit is contained in:
parent
a2447a830c
commit
b99f3e3f36
1 changed files with 10 additions and 4 deletions
|
|
@ -1819,15 +1819,21 @@ def postprocess_ocr_result(vault: Path, key: str, all_results: list[dict]) -> tu
|
|||
artifacts.blocks_raw.parent.mkdir(parents=True, exist_ok=True)
|
||||
artifacts.blocks_structured.parent.mkdir(parents=True, exist_ok=True)
|
||||
all_raw_blocks = build_raw_blocks_for_result_lines(key, all_results)
|
||||
write_raw_blocks_jsonl(artifacts.blocks_raw, all_raw_blocks)
|
||||
|
||||
# Backfill span_metadata from source PDF (not from OCR engine)
|
||||
source_pdf_path = Path(meta.get("source_pdf", "")) if meta.get("source_pdf") else None
|
||||
if source_pdf_path and source_pdf_path.exists():
|
||||
from paperforge.worker.ocr_pdf_spans import backfill_span_metadata_from_pdf
|
||||
from paperforge.worker.ocr_pdf_spans import (
|
||||
backfill_span_metadata_from_pdf,
|
||||
backfill_missing_text_from_pdf,
|
||||
)
|
||||
|
||||
# Attach PDF-derived font/geometry evidence first
|
||||
backfill_span_metadata_from_pdf(all_raw_blocks, source_pdf_path)
|
||||
write_raw_blocks_jsonl(artifacts.blocks_raw, all_raw_blocks)
|
||||
|
||||
# Recover empty OCR text using the same source PDF
|
||||
backfill_missing_text_from_pdf(all_raw_blocks, source_pdf_path)
|
||||
|
||||
write_raw_blocks_jsonl(artifacts.blocks_raw, all_raw_blocks)
|
||||
|
||||
structured, doc_structure = build_structured_blocks(
|
||||
all_raw_blocks,
|
||||
|
|
|
|||
Loading…
Reference in a new issue