ontocast.util.numeric_inventory¶
Domain-agnostic numeric-mention inventory for coverage checking.
Compares numbers stated in a source text against numeric literals present in the extracted graph. The comparison is deliberately verbatim-oriented: extraction is expected to transcribe source values exactly (units are normalized downstream in code, never by the LLM), so a text number missing from the graph is a candidate extraction gap.
canonical_number(text)
¶
Return the canonical decimal form of a numeric string, or None.
Source code in ontocast/util/numeric_inventory.py
extract_numeric_tokens(text, *, ignore_year_like=True)
¶
Extract canonical numeric tokens from free text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Source text. |
required |
ignore_year_like
|
bool
|
Drop bare integers in the 1900-2100 range (years, citation artifacts). Values that also occur with a decimal point are kept. |
True
|
Returns:
| Type | Description |
|---|---|
set[str]
|
Set of canonical decimal strings. |
Source code in ontocast/util/numeric_inventory.py
missing_numeric_mentions(text, graph, *, ignore_year_like=True, limit=30)
¶
Return canonical numbers stated in text but absent from the graph.
The result is capped at limit; when it truncates, a warning records how
many mentions were dropped. Ordering is shortest-first, which is a stable
presentation order, not a relevance ranking -- the caller is advisory
telemetry, so the cap bounds prompt size rather than selecting the most
important gaps.
Source code in ontocast/util/numeric_inventory.py
numeric_literals_in_graph(graph)
¶
Collect canonical numeric values appearing anywhere in graph literals.
Numbers inside label/comment strings count as present: coverage findings target numbers missing from the graph entirely, while structuring label-only numbers is the critic's judgement call.