Repository navigation
feat: add best_effort option and text_unreliable flag - #619
abimaelmartell wants to merge 7 commits into
Conversation
…or OCR A Scanned or ImageBased document returned no Markdown even when it carries a readable (or invisible) text layer, and a Mixed or TextBased document lost its Markdown when the text was judged garbled or its fonts undecodable. PdfOptions::force_extraction(true), and force_extraction=True in the Python process_pdf and process_pdf_bytes, runs extraction anyway and returns what it reads. pdf_type and the OCR page flags are reported as before, so a caller still knows the text may be unreliable. Off by default. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
All reported issues were addressed across 5 files
Shadow auto-approve: would not auto-approve because issues were found.
Fix all with cubic | Re-trigger cubic
…liable The option changes what the library withholds, not what the text is, so it is named for that. The result gains text_unreliable, true when the markdown is text the default would have withheld, so a caller no longer has to infer it from pages_needing_ocr. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
All reported issues were addressed across 6 files (changes from recent commits).
Shadow auto-approve: would not auto-approve because issues were found.
Fix all with cubic | Re-trigger cubic
The per-page CID-garbage strip ran before the markdown-stage gates and dropped the text of OCR-flagged TextBased pages even with best_effort set. It now keeps those pages, still adds the garbled-text reason, and marks the result text_unreliable. The changelog no longer claims the OCR reasons are untouched, and the Python markdown docs no longer say a scanned PDF always has none. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
All reported issues were addressed across 3 files (changes from recent commits).
Shadow auto-approve: would require human review. AI evaluation unavailable; defaulting to comment-only for safety.
Tip: Review your code locally with the cubic CLI to iterate faster.
Fix all with cubic | Turn on auto-fix | Re-trigger cubic
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
1 issue found across 2 files (changes from recent commits).
Confidence score: 5/5
- In
src/lib.rs, the reclassification only runs when markdown is generated, so Mixed PDFs are not reclassified inProcessMode::Analyze. Qualify the statement to modes that generate markdown.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/lib.rs">
<violation number="1" location="src/lib.rs:352">
P2: This reclassification only runs when markdown exists; `ProcessMode::Analyze` sets it to `None`, so a Mixed PDF is not reclassified there. Qualify the statement to modes that generate markdown.</violation>
</file>
Shadow auto-approve: would not auto-approve because issues were found.
Fix all with cubic | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 2 files (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would not auto-approve. Auto-approval blocked by 1 unresolved P0–P2 issue from previous reviews.
Turn on auto-fix | Re-trigger cubic
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
0 issues found across 2 files (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would require human review. Adds opt-in best_effort extraction and text_unreliable flags (Rust/Python); default unchanged. A dismissed finding says the TextBased/OCR-garbage path still drops text; the relevant diff is truncated, leaving that behavior unverified.
Turn on auto-fix | Re-trigger cubic
What
Adds an opt-in
best_effortoption that returns whatever native text can be read, even where the library is not confident in it, and atext_unreliablefield on the result that says when it did.PdfOptions::best_effort(bool),PdfProcessResult::text_unreliableprocess_pdf(path, pages=None, best_effort=False)andprocess_pdf_bytes(...),PdfResult.text_unreliable, stub updatedWhy
Today a Scanned or ImageBased document returns no Markdown, even when it has a readable text layer (or an invisible one behind the scan). A Mixed or TextBased document also loses its Markdown when the text is judged garbled or its fonts undecodable. Callers that want a best-effort result had no way to get it. On a 200-PDF structure benchmark, one such page (165 characters of real text, classified image-based) scored 0.00 and now scores 0.91, lifting the corpus overall score from 0.870 to 0.874.
Behavior
With
best_effortset:pdf_type,pages_needing_ocr,ocr_reasons_by_page,has_encoding_issues), so they remain available alongside the text.text_unreliable.text_unreliableistruewhen the returned Markdown is text the default would have withheld, so a caller does not have to infer it from the OCR flags. It isfalsewithoutbest_effort, and for a document whose text was never withheld.Default behavior is unchanged.
Notes for reviewers
PdfProcessResultgains a public field, so code that builds it with a struct literal needstext_unreliable: false. Two in-repo uses are updated.test_force_extraction_keeps_scanned_text(invisible text layer over a covering image: no Markdown andtext_unreliablefalse by default; Markdown,text_unreliabletrue and the same OCR page flags with the option).cargo fmt,cargo clippy -- -D warningsandcargo testpass. I did not run the pdf-evals regression suite; the default path is untouched.🤖 Generated with Claude Code