feat(pdf): recover compound list-item markers missed by the marker processor#3815
feat(pdf): recover compound list-item markers missed by the marker processor#3815DanielNg0729 wants to merge 2 commits into
Conversation
…ocessor The reading-order stage strips only simple list markers (1., a), [3], .) into ListItem.marker via docling-ibm-models' ListItemMarkerProcessor. Compound and hierarchical markers (9a., 3.a., 1.2.1) are left fused in the text with an empty marker; inside an enumerated list the Markdown serializer then prepends a position-based number, yielding a doubled marker. Add an opt-in ListNormalizationModel that runs after the reading-order model and recovers those markers per list group, only in a numbered context so a lone dotted-decimal value in prose is not mistaken for a marker. Disabled by default (no change to existing output); wired into the standard and legacy PDF pipelines, mirroring the heading-hierarchy stage. Signed-off-by: Daniel Nguyen <danielnguyenh07@gmail.com>
|
✅ DCO Check Passed Thanks @DanielNg0729, all your commits are properly signed off. 🎉 |
Merge Protections🟢 Merge protection satisfied — ready to merge. Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Signed-off-by: Daniel Nguyen <danielnguyenh07@gmail.com>
|
@DanielNg0729 thanks for taking the effort to improve this aspect of list marker identification. Since the docling-ibm-models package already has partial logic, would anything speak against improving the code there instead of adding another layer into docling? |
|
Thank you very much Dr @cau-git I didnt know there was already work for this in docling-ibm-models. I'm happy to move this into the processor instead of adding a stage here. Two things I'd like to check before I open the PR there:
If that sounds good, I'll open a PR against docling-ibm-models adding the compound-marker patterns, and close this one. Thank you! |
|
@DanielNg0729 I see that you opened a new PR on docling-ibm-models for this, thanks. The final pass to apply now is:
|
|
@DanielNg0729 does it mean we can close this PR in favor of docling-project/docling-ibm-models#169 + #3849? |
|
Hi Dr @dolfim-ibm, yes this is superseded by that 2 PR, thank you very much! |
Summary
Hi maintainers, i saw this as a #TODO in the codebase so i try to implement it!
The PDF/image pipeline labels list regions as
LIST_ITEMbut records no ordered-vs-unordered distinction that has to be inferred from the item text. At item-creation time the reading-order stage already runs docling-ibm-models'ListItemMarkerProcessor, which strips simple leading markers (1.,a),[3],•…) intoListItem.markerand setsListItem.enumerated. This covers the common cases behind the recurring# TODO: Infer if this is a numbered or a bullet list item.What it still misses are compound / hierarchical markers —
9a.,3.a.,1.2.1. These stay fused insidetextwith an emptymarker. When such an item sits inside an otherwise-enumerated list, the Markdown serializer sees the empty marker and prepends a position-based number of its own, producing a doubled, wrong marker. Ontests/data/pdf/.../2203.01017v2(the Table-Transformer paper) the algorithm list currently renders:This PR adds an opt-in
ListNormalizationModelthat runs right after the reading-order model and, per list group, recovers those compound markers intomarker(stripping them fromtextand settingenumerated). The same list then renders:Recovery is deliberately conservative:
1.1 million units …) inside a bullet list is never mistaken for a marker.Behavior / compatibility
PdfPipelineOptions.list_normalization_options.enabled, defaultFalse: no change to existing output, so no reference data is regenerated.StandardPdfPipelineandLegacyStandardPdfPipeline, mirroring the existing heading-hierarchy stage.ListNormalizationModel.normalizeoperates on a bareDoclingDocument, so the core is reusable outside the pipeline.How to enable
Checklist: