Document data extraction is useful when a field can be traced back to the source that supports it. Keep a value, its supporting excerpt and its status together. A JSON object can be well formed while the amount, date or identifier inside it is unsupported.
Use missing and unsupported as different outcomes
| Outcome | Record |
|---|---|
| No value found | value: null; status: missing |
| Value and an exact source excerpt | Value, excerpt and source reference |
| Value with no matching excerpt | Quarantine as unsupported |
| Excerpt belongs to another revision | Recheck against the current document hash |
A deterministic source-excerpt check
def validate_extracted_field(record, source):
value, evidence = record.get('value'), record.get('evidence')
if value is None:
return {'status': 'missing', 'value': None}
if not isinstance(evidence, str) or not evidence or evidence not in source:
return {'status': 'unsupported', 'value': None}
return {'status': 'supported_excerpt', 'value': value, 'evidence': evidence}
source = "Invoice fixture. Total: 18"
assert validate_extracted_field({"value": 18, "evidence": "Total: 18"}, source)["status"] == "supported_excerpt"
assert validate_extracted_field({"value": 99, "evidence": "Total: 99"}, source)["status"] == "unsupported"
This local check establishes that an excerpt exists. It does not prove that the excerpt semantically supports the chosen field, that OCR read it correctly, or that two values on a page refer to the same thing. A field-level review still needs labels, units and document context.
Evaluate fields rather than an unexplained accuracy percentage
A Reader extraction is an input to this workflow, not a promise of structured-field or OCR accuracy. No universal OCR accuracy figure is assumed here.
- Freeze a permitted document set and manually label the required fields.
- Include absent fields, repeated amounts, ambiguous dates and scanned inputs.
- Track exact-match errors and unsupported values separately.
- Keep the source revision and review decision with every accepted record.
Reference documentation: www.searchcans.com — /reader-api.