阅读文本 / Reading text
This paper uses synthetic samples to demonstrate the processing method. The code has been verified using examples in an isolated environment; this does not guarantee effectiveness for all real-world files or products. Before processing important files, please retain the original copies and verify them against the boundaries and acceptance criteria outlined in this document.
“Field not found” and “Field is null” may both appear as blank on the user interface, but they should not be treated as equivalent once the program is executed. Furthermore, if the blank is replaced with the numeric value zero, the issue becomes even more insidious: downstream systems receive a valid numerical value, yet mistakenly assume it originates from the original source.
first separates the three states
in the composite contract of this paper,
amount
must exist, and may be a numeric value or
null
. The absence of this key indicates that the output structure is incomplete; the key exists and is
null
indicates that no funds are currently available; zero is a specific numerical value. In real-world business scenarios, other protocols may be used, but they must be clearly documented to avoid leaving each caller to guess on their own.
JSON Schema's
required
is responsible for checking whether the key exists,
type
is responsible for the type of the value. Only
required
, does not automatically prohibit
null
; only in
properties
It lists the fields, yet it still doesn’t automatically require them to appear. These two common misconceptions are well-suited for direct inclusion in regression testing.
uses four inputs to verify the contract
from jsonschema import Draft202012Validator
schema = {"type": "object", "required": ["amount"],
"properties": {"amount": {"type": ["number", "null"]}},
"additionalProperties": False}
validator = Draft202012Validator(schema)
valid = lambda value: not list(validator.iter_errors(value))
assert valid({"amount": None})
assert valid({"amount": 0})
assert not valid({})
assert not valid({"amount": "unknown"})
assert not valid({"amount": None, "guessed": True})
needs to install
jsonschema
. The code performs structural checks in memory, without invoking an extraction model or proving that any amount matches the original text. If exact decimal representation is required for amounts, a separate decimal string protocol may be chosen; do not use this because the example employed
number
simply treats binary floating-point computation as a financial processing scheme.
The interface must also clearly state the status
data
The state that should be expressed
should not be displayed as
does not have an amount key
output contract exception
amount is zero
amount is null
has not been assigned a valid value
extraction successful
amount is 0
has a well-defined zero value
missing
amount is a string unknown
does not comply with this contract
silently passes after being automatically converted to null
Do not insert the reason for the missing value into the numeric field.
If it is necessary to distinguish between “not provided in the original text,” “image unreadable,” and “candidate conflicts,” additional criteria may be added.
status
or
reason
, and define its allowed values. Do not embed the reason as part of an amount string and then have downstream systems extract numbers from it. Unknown is not synonymous with failure: some documents simply do not contain that field, in which case the correct result should retain “unknown.”
pre-delivery inspection source
After the structure has been verified, it is still necessary to check the currency of the amount, its source, and the corresponding tags. When translation and extraction are used in combination, these fields can serve as a post-translation checklist, helping to ensure that key figures have not been inadvertently altered, rather than replacing the original text review. This paper does not claim
OmniDoc (product entry point)
uses this schema internally and does not treat valid JSON as extraction accuracy.
Reference:
JSON Schema object and required
。
- 1 -
Updated 2026-10-08