Skip to main content
Show a reviewer exactly where an extracted value came from: the page and box of each word behind it, ready to draw over the page.
Bank statement with word-level bounding boxes overlaid

Word-level boxes drawn over a bank statement.

What you need

  • The Python SDK and an API key, set up as in Cookbooks.
  • Word boxes enabled for your organization. Without them, a parse that asks for word boxes is refused with a 400; ask support to turn them on.
  • A document to review. This recipe uses the Bank Statement sample, which has 2 pages.

Build it

1

Parse with word boxes

This call parses the statement and waits for it to finish. word_level_bounding_boxes adds every word, with its box, to the result.
Word boxes make a result much larger. Ask for them only on documents someone will review.
2

Extract the value

This code fills a one-field schema from the parse and reads the value with its citation.
3

Read the parse

This code reads the parse, indexes its elements and table cells by id, and keeps its word boxes.
Read the parse only after every step on it has finished: where results are deleted on first read, a parse you’ve already read can’t feed another step.
4

Find the value's words

highlight returns the words a value was read from. For a cited table cell, that’s every word in the cell. For any other element, it’s the element’s words that match the value’s text.
5

Convert the boxes to pixels

A bbox is the four corners of a box, clockwise from the top-left, as fractions of the page’s width and height. This code converts each word’s box to pixels on a page image.
Draw each box over page word.page in your viewer. Store the parse_id, page and box with each review note to draw it again later.

How it works

A value’s citation names a parse element, and that element’s box picks out the word boxes inside it:
  • citation[].element_id is the id of one of the parse’s elements.
  • citation[].sub_element_id, when present, is the id of a cell in that table’s cells.
  • Word boxes are Word elements, with a content, page and bbox, in extensions.word_level_bounding_boxes.

Edge cases

A value with an empty citation list can’t be placed. Neither can a value read from a spreadsheet, whose elements have no bbox, or from a caption without one. Show these values without a highlight.
Matching compares text, so a value can be written differently from its words, such as 1234.5 for “1,234.50”. When no word matches, highlight the whole cited element instead.

Next steps

Elements and bounding boxes

Element ids, box coordinates and word boxes.

Extract

Schemas, citations and confidence scores.