ontocast.tool.ontology_validation.plan¶
The document ontology plan: model-free checks and the reduce-time split.
A plan lists the terms a document adds to its domain. Before any unit renders, each proposal is checked against the whole catalog: a proposal that names a catalog or well-known term becomes a reuse, a parent must exist, and in-plan duplicates collapse. At reduce, a minted term the plan does not name is a candidate: consolidation decides it, and without a decision it is dropped.
A minted term counts as planned when its IRI, its local name (case-insensitive) or one of its labels matches a plan entry. The namespace is not compared: which catalog ontology a unit writes into is the context resolver's choice.
Attributes¶
__all__ = ['PlanIndex', 'PlanAxiomsWritten', 'apply_plan_axioms', 'check_plan', 'compact_iri', 'expand_reference', 'minted_terms', 'plan_candidates', 'term_role']
module-attribute
¶
Classes¶
PlanAxiomsWritten
¶
Bases: NamedTuple
What :func:apply_plan_axioms changed.
Source code in ontocast/tool/ontology_validation/plan.py
PlanIndex
¶
What a minted term is matched against: plan IRIs, local names, labels.
Source code in ontocast/tool/ontology_validation/plan.py
Attributes¶
iris = {term.iri for term in plan.terms}
instance-attribute
¶
labels = {normalize_surface(term.label) for term in plan.terms}
instance-attribute
¶
locals = {term.local_name.casefold() for term in plan.terms}
instance-attribute
¶
Methods:¶
__init__(plan)
¶
Source code in ontocast/tool/ontology_validation/plan.py
covers(iri, graph)
¶
Whether the plan names the term iri declared in graph.
Source code in ontocast/tool/ontology_validation/plan.py
Functions:¶
apply_plan_axioms(graphs, plan, minted)
¶
Write each planned term's parent, domain and range over the render's.
The plan resolved them against the whole catalog; a render sees one unit
and may re-type them. A side is written as the expected class it is
(schema:domainIncludes / schema:rangeIncludes); a datatype range
stays rdfs:range. A minted term matches its plan entry as in
:class:PlanIndex (IRI, else local name). A planned value is written when
it is known or declared in graphs: a term the plan mints but the
document never declared would dangle, so the render's value stays. A value
the plan does not give is left as the render wrote it.
Returns:
| Type | Description |
|---|---|
PlanAxiomsWritten
|
The number of sides and of parents changed. |
Source code in ontocast/tool/ontology_validation/plan.py
check_plan(report, *, home, catalog_index, prefixes, max_terms)
¶
Accept, convert to reuse, or refuse each proposal, without a model.
Rules, in order:
- A proposal whose
reusenames a known term of compatible role is a reuse of that term. - A proposal whose label or local name names exactly one catalog term of compatible role is a reuse of it.
- A second proposal with the same local name or label is refused.
- Past
max_termsaccepted entries, proposals are refused. - Anything else is minted under the home namespace.
- A parent must be a known term or another accepted entry; an unknown parent is dropped and the term kept.
- A minted property's domain and range must be a known class or a class the plan mints (a datatype for a datatype property's range); an unknown one is dropped and the term kept. A generic upper class is kept and counted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
report
|
OntologyPlanReport
|
The model's proposals. |
required |
home
|
OntologyIdentity
|
The document's home ontology; minted IRIs live in its namespace. |
required |
catalog_index
|
CatalogSurfaceIndex
|
Names of every catalog term. |
required |
prefixes
|
Mapping[str, str]
|
CURIE prefixes the prompt showed, prefix to namespace. |
required |
max_terms
|
int
|
Largest number of accepted entries. |
required |
Returns:
| Type | Description |
|---|---|
OntologyPlan
|
The accepted plan, with refusals recorded. |
Source code in ontocast/tool/ontology_validation/plan.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
compact_iri(iri, prefixes)
¶
prefix:local for iri under the longest matching namespace.
Source code in ontocast/tool/ontology_validation/plan.py
expand_reference(reference, prefixes)
¶
An IRI for reference: a full IRI, <IRI>, or a known CURIE.
Returns:
| Type | Description |
|---|---|
str | None
|
The IRI, or |
str | None
|
prefix. |
Source code in ontocast/tool/ontology_validation/plan.py
minted_terms(graphs, catalog_index)
¶
Terms the graphs declare that neither the catalog nor a well-known
vocabulary holds, with their role (class or property).
Source code in ontocast/tool/ontology_validation/plan.py
plan_candidates(graphs, plan, catalog_index)
¶
Minted terms the plan does not name; none when there is no plan.