docling-project / docling-project/docling-core

Feature: Add a `DocItem`-level field linking body text to the footnotes it cites

Open
#757 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
HTML
Stars
282
Forks
214
Avg merge
2d 15h
Merged PRs (30d)
21

Description

A `FloatingItem` (table, picture) can already point at its own footnotes (`footnotes: list[RefItem]`), but a plain paragraph cannot, even though `DocItem` already carries the equivalent for comments (`comments: list[FineRef]`). At present, therefore, nothing in `DoclingDocument` records that a paragraph's text cites a particular `FOOTNOTE` item. The connection exists only implicitly, in tree order. By contrast, the PDF
pipeline's does match footnotes to tables/pictures).

I propose adding one field to `DocItem`, mirroring `comments` exactly:

```python
footnote_refs: list[FineRef] = [] # footnotes this item's text cites, each range
# giving the marker's character span in this item's text
```

For example, a paragraph "The claimant relies on the report² for this
figure." with footnote 2 reading "Expert report, exhibit 4." would carry:

```json
{
"self_ref": "#/texts/40",
"text": "The claimant relies on the report for this figure.",
"footnote_refs": [{"$ref": "#/texts/41", "range": [33, 39]}]
}
```

In the first instance, this would be a change to the schema only. If you think this is a sensible addition as a first step, I am happy to have a go at looking at implementing better footnote matching in the PDF (and maybe docx) parsers.

(cc: @ggozad)

Contributor guide

Open the contributing guide

Research direction

Start with the DocItem schema and its existing comments: list[FineRef] field, then compare how FloatingItem stores footnotes. Add the proposed footnote_refs field with the stated reference and range shape, and verify that a DoclingDocument paragraph can serialize it as shown.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.