feat(detector): Scan all pages with early-exit for reliable classification
Change max_pages_to_sample from 5 to u32::MAX so every page is analyzed. This prevents misclassifying Mixed PDFs as TextBased when scanned pages fall outside the old 5-page sample window. Add early-exit: stop scanning as soon as a non-text page is found, since the PDF can't be purely TextBased. A 492-page mixed PDF exits after 2 pages instead of scanning all 492. Also add title and confidence fields to PdfProcessResult for downstream consumers (NAPI wrapper, feature-flag gating). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
b929bbd92e
commit
f54a296c44
@@ -56,7 +56,7 @@ fn make_text_item_with_font(
|
||||
#[test]
|
||||
fn test_detection_config_default() {
|
||||
let config = DetectionConfig::default();
|
||||
assert_eq!(config.max_pages_to_sample, 5);
|
||||
assert_eq!(config.max_pages_to_sample, u32::MAX);
|
||||
assert_eq!(config.min_text_ops_per_page, 3);
|
||||
assert!((config.text_page_ratio_threshold - 0.6).abs() < 0.001);
|
||||
}
|
||||
@@ -863,6 +863,8 @@ fn test_pages_needing_ocr_field_accessible() {
|
||||
page_count: 1,
|
||||
processing_time_ms: 0,
|
||||
pages_needing_ocr: vec![1, 3],
|
||||
title: None,
|
||||
confidence: 1.0,
|
||||
};
|
||||
assert_eq!(process_result.pages_needing_ocr, vec![1, 3]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user