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:
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:
{
"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)
A
FloatingItem(table, picture) can already point at its own footnotes (footnotes: list[RefItem]), but a plain paragraph cannot, even thoughDocItemalready carries the equivalent for comments (comments: list[FineRef]). At present, therefore, nothing inDoclingDocumentrecords that a paragraph's text cites a particularFOOTNOTEitem. The connection exists only implicitly, in tree order. By contrast, the PDFpipeline's does match footnotes to tables/pictures).
I propose adding one field to
DocItem, mirroringcommentsexactly:For example, a paragraph "The claimant relies on the report² for this
figure." with footnote 2 reading "Expert report, exhibit 4." would carry:
{ "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)