feat: per-page OCR routing reasons (#139)
* feat: per-page OCR routing reasons (scanned/no_text/vector_text/garbled) Replaces the single suspected_garbled_text signal with a per-page explanation for why each OCR-flagged page needs OCR. The detector classifies each page in pages_needing_ocr from its content analysis: - scanned — no usable text, image-backed page - no_text — no text and no image (blank/unreachable) - vector_text — text drawn as vector outlines, not extractable - suspected_garbled_text — undecodable Identity-H/Type3 fonts Exposed on PdfTypeResult.ocr_reasons_by_page and surfaced through PdfProcessResult and the detect-pdf CLI (JSON + human output). Reasons only ever explain pages already flagged for OCR — a text page with an embedded logo stays TextBased, so this doesn't widen the OCR net. Markdown output is byte-identical across the regression corpus. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * review: cache freshly-analyzed pages so OCR reasons aren't lost Under a sampling ScanStrategy, the Mixed per-page loop (Phase 2) and the garbled-font check (Phase 3) analyze non-sampled pages but dropped the PageAnalysis after flagging them. The reason-classification pass then missed the cache and defaulted those pages to "scanned", masking the real vector_text / suspected_garbled_text cause. Insert the fresh analyses into analysis_cache so the reason pass classifies them correctly. No change under the default full-sampling strategy (all pages are already cached). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
a38efcf142
commit
d8eb33e390
@@ -1102,6 +1102,7 @@ fn test_pages_needing_ocr_field_accessible() {
|
||||
title: None,
|
||||
ocr_recommended: false,
|
||||
pages_needing_ocr: Vec::new(),
|
||||
ocr_reasons_by_page: std::collections::BTreeMap::new(),
|
||||
};
|
||||
assert!(detection_result.pages_needing_ocr.is_empty());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user