verify - check the values another reader returned
truecopy/verify
A model or an extraction API hands back values. verify reads the document itself and answers, for each value under the label of its row, confirmed, contradicted or not found.
Another reader already did the reading: a model looking at the page image, an extraction API. This module does not read in its place. It takes each value it returned, under the label of its row, and says what the document prints there.
import { verify, verifyValues } from 'truecopy/verify';
One call
import { verify } from 'truecopy/verify';
const checked = await verify(file, [
{ value: '8 430', label: 'Total assets' },
{ value: '8 340', label: 'Total assets' },
{ value: '1 250', label: 'Inventories' },
{ value: '512', label: 'Goodwill' }
]);
On a three-line balance sheet that prints Inventories 1 250 1 180 and Total assets 8 430 7 990, run against truecopy 2.0.26:
confirmed labelled: true row: 3
contradicted labelled: true row: 3 printed: [ '8 430', '7 990' ]
confirmed labelled: true row: 2
not-found labelled: false
The answers come back in the order the claims were given, one CheckedValue per ClaimedValue.
Standing: the three answers
confirmed: a row the label names prints the figure.contradicted: the rows that open on the label print other figures, and every one of them was read with confidence.printedlists them.not-found: neither. This is not a verdict on the value. It says the document, read this way, does not settle it.
A label is read letter by letter, so Inventor ies from a text layer still names Inventories. A label of one or two characters names nothing.
ClaimedValue
value: a number, or a string. A string with a digit and no letter is a figure; otherwise it is words.label: the words that name its row. Without it a figure can only be found somewhere or not found, never contradicted, and found somewhere is a much smaller claim.page: the page it was read from,1for the first. Left out, every page answers.
CheckedValue
standing: one of the three above.labelled: whether a row the label names answered. Aconfirmedwithfalsewas claimed with no label: the value is printed, and nothing says on which row. Anot-foundwithfalseunder a label means the document prints that label nowhere.pageandrow: where the answering row is,rowcounting from1, soTable.rows[row - 1].placeandconfidence: on aconfirmedonly, where the confirming cell sits and how far it was trusted on its own. The confidence is informative; the agreement of two readers is what confirmed it.printed: on acontradictedonly, the figures the row prints instead.
VerifyOptions
written: the decimal mark the claims are written with, when it is not the document’s. A model asked for JSON writes1234.5for a page that prints1 234,5.brackets: what brackets around a figure mean on this document. A sign unless said.
verify(file, claims, options?) and verifyValues(table, claims, options?)
verify reads the file itself, with the default cut and the confidence of each cell, and refuses the cut options on purpose: the confidence was measured on the default cut and claims nothing past it. It also takes the options of open.
verifyValues does the same on a reading you already hold. Read the table with confidence: true: without the score of each cell nothing is ever contradicted, except on a delimited file.
The MCP server carries the same check as verify_values.
What it cannot see
The column. A figure confirmed on its row may be last year’s: 8 430 and 7 990 sit on the same row, and either one is confirmed under Total assets.
Where to go next
- Check what a model extracted - the arithmetic check against the total the document declares.
- cite - make the model point at the rows it read, and look the value up there.
- How do you know the reading is right? - the checks, and the one thing none of them prove.