Checking a text¶
rainfall_thresholds.check ¶
Check that a text quotes the facts: no number invented, none in the wrong unit.
A model turns the facts of :mod:rainfall_thresholds.facts into words. The
faults that matter here are three:
- invented: a number that is in no fact;
- unit: a number that is a fact, but of another unit. The classic one: the 30.9 mm the threshold asks for over 35 hours, written as 30.9 mm/h. A rainfall threshold is about both, and they differ by the duration;
- rounded: a number close to a fact, but not the fact rounded to the
decimals written (
118.1for 118.04).
A number may be written with fewer decimals than the fact (31 for
30.9) or, from 100, as a round number (1,600 for 1,603). Dates, years and
clock times (10/10, 10 October 2026, 2026-10-10, 03:00) are
not checked, nor numbers that are in the question. The check knows that
a number is a fact of the right unit, not that it is said of the right
thing: "Melito got 30.9 mm" passes when 30.9 mm is the threshold.
Misquote
dataclass
¶
A number of the text that is not a fact as written.
facts_of ¶
facts_of(facts: Any, path: str = '') -> Iterator[tuple[str, float, str | None]]
Every number in facts, with its path and the unit its key names.
parse_number ¶
parse_number(token: str) -> tuple[float, int]
A number as written -> its value and its decimals. 1,603 is 1603; 2,5 is 2.5.
check_text ¶
check_text(text: str, facts: Any, *, question: str = '') -> list[Misquote]
The numbers of text that are not facts of their unit. Empty: faithful.