Menu

Extracting invoice fields with validation: what auto-posts and what goes to a human
📰

Extracting invoice fields with validation: what auto-posts and what goes to a human

DEV Community: python·Slava Kotenev·about 7 hours ago
#dmmR7FaL
#devtopython#devto#dev#invoice#field
Reading 0:00
15s threshold

Pulling an invoice number or a total out of text is the easy half of the job. The useful half is deciding, for every field of every document, whether it goes straight into the accounting system or lands on a person's desk. Here is how a small demo handles it. Everything below is test data from a public synthetic dataset, not a client result.

What the demo does

Input: the OCR text of an invoice. Output: invoice number, date, IBAN and gross total, each with a confidence. Fields with low confidence are routed to a human instead of being posted.

The data is mychen76/invoices-and-receipts_ocr_v1 : OCR text plus ground-truth fields. The invoices are synthetic with a fixed layout, and only the invoice-type documents are used (484 of about 2,200; the rest are receipts with a different schema).

Candidates first, then a ranker

For each field the code generates candidates with patterns, then a small logistic regression picks the right one using context: the words around the candidate, its position, its format.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.