Skip to content

Citations and confidence

Every value ReadAnyDoc returns can say where it came from: the page, a box on that page, and the exact text that was read there. This is what lets a person check an extracted value in one click.

In Parse

Each block has a bbox (page, left, top, width, height as fractions of the page) and a confidence. With citations on, text blocks also get word positions and tables get cell positions:

result = readanydoc.parse("statement.pdf", citations=True)
block = result.blocks[3]
block.bbox           # BoundingBox(page=1, left=0.08, top=0.31, width=0.84, height=0.05)
block.confidence     # "high" or "low"
result.raw           # the full Reducto-shaped response, including word and cell citations
{"input": "...", "settings": {"return_citations": true}}

Text blocks carry extra.word_citations, tables carry cell_citations, in Reducto's shape.

In Extract

Citations are on by default in the library. Every leaf value of your schema maps to its sources:

out = readanydoc.extract("invoice.pdf", schema=Invoice)
out.citations["total"]            # [Citation(content="£1,575.00", bbox=..., confidence="high")]
out.citations["lines[0].amount"]  # paths use dots and [index]

Rules ReadAnyDoc follows:

  • The cited text is the text that matched the value, including punctuation the value itself carries ("Inc.").
  • One box per printed word; a value spread over several words gets the boxes that hold it.
  • A value whose source block does not contain it gets a block-level citation marked low.
  • A value with no source that can be located gets an empty list. ReadAnyDoc never invents a position.

Confidence

Confidence is a tier, high or low, from how a value was found: agreement between independent reads, a match in the PDF's own text, a checked total. It is not a calibrated probability. Use it to decide what a person should look at first, not as a percentage.