Skip to main content
The extraction subsystem converts tagged document content into structured data objects and attributes using taxonomy definitions. It runs in the Go core via CFFI for performance.

Core Concepts

  • Taxonomy — Defines the structure of data to extract (groups, fields, types)
  • ExtractionEngine — Processes a document against taxonomies to produce data objects
  • DataObject — A structured record extracted from the document (e.g., an invoice header)
  • DataAttribute — A field within a data object (e.g., invoice number, date, total)
  • DataException — A validation error on a data object or attribute

Taxonomy

A Taxonomy wraps a Go-side taxonomy handle for use with the extraction engine. Create one from a dict or a JSON file path:
Taxonomies implement the context manager protocol and should be closed when no longer needed:
If you don’t use a context manager, the Go handle is still cleaned up automatically via weakref.finalize, but using with is recommended for deterministic cleanup.

ExtractionEngine

The ExtractionEngine processes a document against one or more taxonomies to extract structured data.

Constructor

process_and_save

Runs extraction and persists the results (data objects, attributes, exceptions) into the document’s SQLite store:

Content Exceptions

After extraction, retrieve any content-level exceptions:

Document Taxon Validations

Check which taxons were found or missing in the document:

DataObject

Represents a structured record extracted from the document. Created by the extraction engine, accessed via DataObjectAccessor.

DataAttribute

A field value within a data object.

DataException

A validation error attached to a data object or attribute.

DocumentTaxonValidation

Reports whether a specific taxon was found during extraction.

Complete Example