ontocast.prompt.ontology_context¶
Helpers for deriving prompt-ready domain ontology namespace context.
build_label_index(graph)
¶
Build a label→IRI index for ontologies with opaque local names.
Only emits a section when the graph contains opaque IRIs (Wikidata-style Q/P codes, hash IDs, etc.) so the LLM can map text mentions to canonical IRIs. Returns an empty string when all local names are already human-readable.
Source code in ontocast/prompt/ontology_context.py
build_ontology_index(graph)
¶
Combine label index and property summary into a single prompt appendix.
Returns an empty string when the ontology does not use opaque IRIs.
Source code in ontocast/prompt/ontology_context.py
build_property_summary(graph)
¶
Build a resolved property summary for ontologies with opaque local names.
Resolves domain/range opaque IRIs to their rdfs:label so the LLM does not need to mentally join triples. Returns an empty string when no properties with opaque IRIs are found.
Source code in ontocast/prompt/ontology_context.py
extract_domain_prefix_pairs(ontology)
¶
Return domain prefix/namespace pairs present in ontology graph.
Source code in ontocast/prompt/ontology_context.py
format_ontologies_clause(pairs)
¶
Format a human-readable ontology clause including prefix and namespace for prompts.
Produces e.g. "domain ontology fcaont: (https://example.org/fcaont/)" so a
single variable conveys both which prefix to use and which namespace it maps to.