ontocast.tool.triple_manager.util¶
Shared helpers for triple store backends.
dedupe_terminal_ontologies(all_ontologies)
¶
Keep the latest terminal version per ontology IRI.
Works on anything carrying lineage metadata, so the same selection runs over
materialized :class:~ontocast.onto.ontology.Ontology objects and over
graph-less :class:~ontocast.onto.ontology_header.OntologyHeader records.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
all_ontologies
|
Sequence[LineageT]
|
Every stored version, across all IRIs. The parent-hash sweep needs the full set, not just candidate terminals. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
list[LineageT]
|
One entry per distinct IRI, of the same type that was passed in. |
Source code in ontocast/tool/triple_manager/util.py
deterministic_turtle_serialization(graph)
¶
Create a deterministic Turtle serialization of an RDF graph.
Source code in ontocast/tool/triple_manager/util.py
headers_from_select_rows(rows)
¶
Fold :data:ONTOLOGY_HEADER_QUERY rows into one header per named graph.
?parent is multi-valued, so the query returns a small cross product; rows
sharing a (?g, ?onto) pair describe one ontology version and are merged,
accumulating parent_hashes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rows
|
Iterable[dict[str, str]]
|
SELECT bindings, each mapping variable name to lexical value. |
required |
Returns:
| Type | Description |
|---|---|
list[OntologyHeader]
|
list[OntologyHeader]: One header per stored ontology version, ordered by |
list[OntologyHeader]
|
graph URI for determinism. |
Source code in ontocast/tool/triple_manager/util.py
ontology_from_named_graph(graph_uri, graph)
¶
Build an :class:Ontology from a named-graph export.
Source code in ontocast/tool/triple_manager/util.py
ontology_iri_for_named_graph(graph_uri, ontology_subject)
¶
Resolve the catalog IRI for an ontology stored in graph_uri.
A versioned graph name (<iri>#<hash>) identifies the ontology by its base
IRI; an unversioned graph name defers to the owl:Ontology subject.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph_uri
|
str
|
Named graph URI the ontology was read from. |
required |
ontology_subject
|
str
|
Subject typed |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The ontology's catalog IRI. |