ontocast.tool.curation¶
Curate a catalog ontology across the documents that grew it.
A term one document added and no other document uses is the definition of a document-level term, and only a pass over the catalog can see it. Curation:
- attributes every term of the head to the version that introduced it, and
that version to the document its header names (
prov:wasDerivedFrom); terms of a version with no document (a seed file, an upload) are authored and never curated; - counts, per term, the documents whose facts use it, when the facts store answers SPARQL;
- flags terms without a model: used by at most one document, unused, a name variant, a value-set family, or a duplicate of an authored term;
- asks the model for an action on the flagged terms only, in batches;
- compiles the actions into one update of the head, written as a new version on request.
Attributes¶
CURATION_SOURCE_PREFIX = 'urn:ontocast:curation:'
module-attribute
¶
__all__ = ['CuratedTerm', 'CurationReport', 'attribute_terms', 'curate_catalog', 'curate_ontology', 'facts_usage']
module-attribute
¶
logger = logging.getLogger(__name__)
module-attribute
¶
Classes¶
CuratedTerm
¶
Bases: BaseModel
One term a document added, with what curation knows about it.
Source code in ontocast/tool/curation.py
CurationReport
¶
Bases: BaseModel
What curation found and decided for one ontology.
Source code in ontocast/tool/curation.py
Attributes¶
actions = Field(default_factory=dict, description="Decided action per reviewed term: 'merge_into <iri>' etc.")
class-attribute
instance-attribute
¶
authored_terms = 0
class-attribute
instance-attribute
¶
calls = 0
class-attribute
instance-attribute
¶
calls_failed = 0
class-attribute
instance-attribute
¶
head_version_iri = None
class-attribute
instance-attribute
¶
ignored = Field(default_factory=list)
class-attribute
instance-attribute
¶
ontology_iri
instance-attribute
¶
predicted_version = None
class-attribute
instance-attribute
¶
terms = Field(default_factory=list)
class-attribute
instance-attribute
¶
triples_deleted = 0
class-attribute
instance-attribute
¶
triples_inserted = 0
class-attribute
instance-attribute
¶
written_version_iri = None
class-attribute
instance-attribute
¶
Functions:¶
attribute_terms(tools, head)
async
¶
Which document introduced each term of head.
A term is introduced by the version that declares it while none of that
version's priors does. Each version's header names its own source
(prov:wasDerivedFrom is rewritten per version).
The lineage is walked from the versions the manager holds through
owl:priorVersion: a manager loaded from a triple store holds only each
ontology's head, and an unvisited prior would leave every term it
introduced counted as authored. A version not held is read from its stored
graph, whose header carries its priors, its date and its source.
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
|
dict[str, str]
|
role for terms of versions with no document. |
Source code in ontocast/tool/curation.py
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 | |
curate_catalog(tools, *, ontology=None, apply=False, batch_size=40, use_facts=True)
async
¶
Curate one catalog ontology, or every one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tools
|
ToolBox
|
An initialised toolbox; its catalog and facts store are read. |
required |
ontology
|
str | None
|
An ontology id, alias or IRI; every head when None. |
None
|
apply
|
bool
|
Write each changed ontology as a new version. Otherwise only report. |
False
|
batch_size
|
int
|
Flagged terms per model call. |
40
|
use_facts
|
bool
|
Count, per term, the documents whose facts use it. |
True
|
Raises:
| Type | Description |
|---|---|
ValueError
|
|
AmbiguousOntologyRefError
|
|
DivergedOntologyError
|
the named ontology has several heads. |
Source code in ontocast/tool/curation.py
curate_ontology(tools, head, *, apply=False, batch_size=40, use_facts=True)
async
¶
Curate one catalog ontology; see the module docstring.
Source code in ontocast/tool/curation.py
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 | |
facts_usage(tools)
async
¶
Documents whose facts use each type or predicate, from the facts store.
None when no store answers SPARQL. A document is one named graph of the facts partition.
Source code in ontocast/tool/curation.py
version_source(version, graph)
¶
The document a version's header says it was derived from, if any.