Skip to content

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

Description

@lawrenceakka

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions