Save Groundings as Images
What Is a “Grounding”?
When parses a document, it breaks the content into chunks, which are discrete elements extracted from a document, like blocks of text or tables.
Each chunk includes a grounding, which represents the location of the chunk in the document. The grounding includes:
- the page number that the chunk is on
- the relative coordinates of the bounding box of the chunk
For example, below is the JSON output for a text
chunk. The grounding
object indicates that the text is on the first page, and the box
object indicates the bounding box coordinates.
Save Groundings as Images
When using any of the parsing functions from the library, you can use the optional grounding_save_dir
parameter to save each grounding as an image. The images are saved to a directory you specify.
Here’s an example of how to use the grounding_save_dir
parameter with the parse_documents
parsing function:
File Path and File Name Conventions for Saved Groundings
Images are saved with this structure:
Where:
TIMESTAMP
is the time and date the document was parsedpage_0
is the page numberTYPE
is the chunk typeCHUNK_ID
is the chunk IDY
is the index of the grounding (in case a chunk spans multiple regions)