Repository navigation
fix: Docling parser extracts mathematical formulas - #16645
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughDocling parser now conditionally imports pipeline-related classes, extracts formulas inline during document iteration, skips empty equation payloads, and enables optional LaTeX formula enrichment for local conversion via a new environment variable, documented in the PDF parser guide. ChangesDocling formula handling
Estimated code review effort: 2 (Simple) | ~15 minutes Sequence Diagram(s)sequenceDiagram
participant ParsePdf as parse_pdf
participant PipelineOptions as PdfPipelineOptions
participant Converter as DocumentConverter
participant DocItems as _iter_doc_items
participant Sections as _transfer_to_sections
ParsePdf->>PipelineOptions: set do_formula_enrichment from env var
ParsePdf->>Converter: create with format_options(InputFormat.PDF, pipeline_options)
Converter-->>ParsePdf: conv_res (parsed document)
ParsePdf->>DocItems: iterate doc.texts
DocItems->>DocItems: yield equation when label == "formula"
DocItems-->>Sections: sections including equations
Sections->>Sections: skip empty equation payloads
Sections-->>ParsePdf: final sections
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@deepdoc/parser/docling_parser.py`:
- Around line 566-568: The new PDF pipeline setup in docling_parser should not
parse DOCLING_FORMULA_ENRICHMENT with int() because non-numeric values can crash
parsing; update the PdfPipelineOptions setup to use safe boolean/env parsing in
the same flow that builds DocumentConverter. Also add a self.logger message
around the pipeline_options / do_formula_enrichment decision so this new
conversion path is logged consistently with the rest of the parser.
- Around line 225-231: The formula handling in docling_parser’s label ==
"formula" branch is using plain text first, but the enriched LaTeX is available
in the enrichment payload. Update the logic in the formula extraction path to
read enriched_data["latex"] or "tex" before falling back to orig or text, while
keeping the existing bbox extraction and DoclingContentType.EQUATION yield
behavior unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f34e9a80-8b57-46be-bca0-b1030381e252
📒 Files selected for processing (2)
deepdoc/parser/docling_parser.pydocs/guides/dataset/select_pdf_parser.md
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16645 +/- ##
=======================================
Coverage 93.16% 93.16%
=======================================
Files 10 10
Lines 717 717
Branches 118 118
=======================================
Hits 668 668
Misses 29 29
Partials 20 20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Before:
After:
After (DOCLING_FORMULA_ENRICHMENT="1"):
Fixes #16644