ontocast.check¶
Model-free checks of a user-supplied facts graph.
Modules:
| Name | Description |
|---|---|
facts |
Check a user-supplied facts graph against a catalog, without a model. |
messages |
Messages of the facts check, one per kind, written for a person. |
report |
Report models for the facts check. |
scope |
Which subjects of a facts graph are instances. |
Attributes¶
__all__ = ['FactsCheckFinding', 'FactsCheckKind', 'FactsCheckMetrics', 'FactsCheckReport', 'catalog_schema_terms', 'check_facts', 'declared_terms', 'instances']
module-attribute
¶
Classes¶
FactsCheckFinding
¶
Bases: BaseModel
One problem found in a facts graph.
Source code in ontocast/check/report.py
Attributes¶
kind
instance-attribute
¶
message
instance-attribute
¶
predicate = None
class-attribute
instance-attribute
¶
severity
instance-attribute
¶
source_shape = None
class-attribute
instance-attribute
¶
subject = None
class-attribute
instance-attribute
¶
suggestions = Field(default_factory=list)
class-attribute
instance-attribute
¶
value = None
class-attribute
instance-attribute
¶
FactsCheckKind
¶
Bases: StrEnum
Kind of a finding; the value is the snake_case member name.
Source code in ontocast/check/report.py
Attributes¶
CATALOG_SUBJECT = 'catalog_subject'
class-attribute
instance-attribute
¶
DANGLING_REFERENCE = 'dangling_reference'
class-attribute
instance-attribute
¶
DOMAIN_VIOLATION = 'domain_violation'
class-attribute
instance-attribute
¶
FUNCTIONAL_VIOLATION = 'functional_violation'
class-attribute
instance-attribute
¶
INVALID_LITERAL = 'invalid_literal'
class-attribute
instance-attribute
¶
ISOLATED_INSTANCE = 'isolated_instance'
class-attribute
instance-attribute
¶
NON_CATALOG_VOCABULARY = 'non_catalog_vocabulary'
class-attribute
instance-attribute
¶
SCHEMA_IN_FACTS = 'schema_in_facts'
class-attribute
instance-attribute
¶
SHACL = 'shacl'
class-attribute
instance-attribute
¶
SILENT_INSTANCE = 'silent_instance'
class-attribute
instance-attribute
¶
TEMPORAL_RANGE_MISMATCH = 'temporal_range_mismatch'
class-attribute
instance-attribute
¶
TWIN_LABELS = 'twin_labels'
class-attribute
instance-attribute
¶
UNKNOWN_TERM = 'unknown_term'
class-attribute
instance-attribute
¶
UNTYPED_INSTANCE = 'untyped_instance'
class-attribute
instance-attribute
¶
UNTYPED_VALUE = 'untyped_value'
class-attribute
instance-attribute
¶
FactsCheckMetrics
¶
Bases: BaseModel
Size and shape figures of the checked graph.
Source code in ontocast/check/report.py
FactsCheckReport
¶
Bases: BaseModel
Outcome of a facts check.
counts maps kind value to severity to number of findings and is complete
even when findings is truncated; findings_total is the untruncated count.
Source code in ontocast/check/report.py
Functions:¶
catalog_schema_terms(catalog)
¶
Return the IRIs the catalog declares as a class or property.
Evidence is explicit typing, a domain or range, rdfs:subClassOf,
rdfs:subPropertyOf and rdf:type-object position. The catalog's
individuals (ex:Paris a ex:City, SKOS concepts, units) are not terms:
statements about them are facts.
Source code in ontocast/check/scope.py
check_facts(graph, ontology_graph, shapes_graph=None, *, vocabulary='strict', additional_standard_namespaces=(), instance_namespaces=None, max_findings=None, shacl_max_triples=0)
¶
Check a facts graph against a catalog ontology and report what is wrong.
The graph is never modified: every check that rewrites runs on a copy.
With an empty or missing catalog, the checks that need one are skipped
and the report says so (catalog_empty); the well-known-term checks
and literal syntax still run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
Graph
|
Facts graph, in the user's own namespaces. |
required |
ontology_graph
|
Graph | None
|
Merged catalog ontology; |
required |
shapes_graph
|
Graph | None
|
Merged SHACL shapes, or |
None
|
vocabulary
|
Vocabulary
|
|
'strict'
|
additional_standard_namespaces
|
Sequence[str]
|
Namespaces treated like the standard vocabularies. |
()
|
instance_namespaces
|
Sequence[str] | None
|
When given, only subjects under these namespaces are instances. |
None
|
max_findings
|
int | None
|
Cap on the returned findings; |
None
|
shacl_max_triples
|
int
|
Skip SHACL validation above this many triples; 0 means no limit. |
0
|
Returns:
| Type | Description |
|---|---|
FactsCheckReport
|
The report. |
Source code in ontocast/check/facts.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 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 | |
declared_terms(graph)
¶
Return IRIs the graph itself declares as a class or property.
Source code in ontocast/check/scope.py
instances(graph, *, catalog_terms, standard_namespaces, restrict_to=None)
¶
Return the IRI subjects of graph that are instances.
An instance is not a catalog term (a class or property,
:func:catalog_schema_terms), not declared in the graph, and not under
a standard or well-known namespace. Blank-node and literal subjects are
ignored. With restrict_to, only IRIs under those namespaces are kept.