ontocast.tool.vector_store.query_signals¶
Query-side unit/quantity signals for deterministic seed injection.
A number adjacent to a short token ("4-15 days", "200 kV", "0.5 %",
"77 K") is strong evidence of a unit mention — strong enough to justify a
more permissive match than the general lexical-trigger lane: catalog
surface forms (labels, symbols, UCUM codes) are compared
case-insensitively and plural-tolerantly, so text "days" reaches
unit:DAY (label "Day", symbol "d") even though the case-sensitive
trigger lane never could.
Matched values come from the catalog at runtime. The surface predicates
are supplied by the caller (see VECTOR_STORE_INDUCED_SUBGRAPH_SYMBOL_PREDICATES);
the module-level defaults below are the same overridable defaults the
lexical-trigger lane uses, not a hardcoded vocabulary.
The token heuristics are Latin-script and English-centric: _STOP_TOKENS
is an English function-word list, and the plural rule strips a trailing
"s". Both only ever suppress or widen candidate tokens, so a non-English
corpus loses recall on this additive lane rather than extracting wrongly.
CatalogSurfaceIndex
¶
Case-insensitive surface-form index over catalog ontologies.
Maps lowered labels/symbols/UCUM codes to entity IRIs, cached per ontology (iri, hash) so repeat retrievals are dictionary lookups.
Source code in ontocast/tool/vector_store/query_signals.py
__init__(symbol_predicates=None)
¶
Build the index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol_predicates
|
Sequence[URIRef] | None
|
Catalog symbol/notation predicates to index in
addition to the standard name predicates. Supplied from
configuration by the retriever; |
None
|
Source code in ontocast/tool/vector_store/query_signals.py
match(tokens, ontologies)
¶
Match candidate tokens against catalog surface forms.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tokens
|
Iterable[str]
|
Number-adjacent candidate tokens. |
required |
ontologies
|
Sequence[Ontology]
|
Catalog ontologies to match against. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
Mapping of matched entity IRI -> owning ontology IRI. |
Source code in ontocast/tool/vector_store/query_signals.py
number_adjacent_tokens(text)
¶
Extract candidate unit tokens that directly follow numbers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Source text of one content unit / query window. |
required |
Returns:
| Type | Description |
|---|---|
set[str]
|
Set of case-preserved candidate tokens. |