ontocast.stategraph.unit_exit¶
What leaves the unit loop: one exit action per finding kind.
The unit loop keeps serving a content unit the critic did not accept, but no
statement a deterministic check rejected leaves it. :data:EXIT_ACTIONS says,
for every kind a unit finding can have, what happens to the statements an
unresolved finding of that kind names when the unit leaves the loop, after
the gap pass. A finding about an absence -- a missing role, a missing number,
a missing type -- or about no single statement (results that disagree in
dimension name no one wrong number) cannot be repaired by removing one, so it
is reported: it stays on the unit and is counted in the document report.
Attributes¶
ABSENCE_KINDS = frozenset({FactsUnitFindingKind.NUMERIC_COVERAGE, FactsUnitFindingKind.LABEL_ONLY_NUMBER, FactsUnitFindingKind.SCALAR_AS_BOUNDS, FactsUnitFindingKind.UNTYPED_INSTANCE, FactsUnitFindingKind.MISSING_ROLE, FactsUnitFindingKind.DIMENSION_CONFLICT, FactsUnitFindingKind.DOMAIN_ADHERENCE})
module-attribute
¶
EXIT_ACTIONS = {FactsUnitFindingKind.QUARANTINED_LITERAL: ExitAction.WRITE_BACK, FactsUnitFindingKind.UNKNOWN_TERM: ExitAction.DROP_TERM, FactsUnitFindingKind.LITERAL_TYPE_OBJECT: ExitAction.DROP_TRIPLE, FactsUnitFindingKind.DOMAIN_VIOLATION: ExitAction.DROP_STATEMENTS, FactsUnitFindingKind.ROLE_OUTSIDE_STATEMENT: ExitAction.DROP_LINK, FactsUnitFindingKind.UNGROUNDED_NUMBER: ExitAction.DROP_NUMBER, FactsUnitFindingKind.CONTRADICTED_INDIVIDUAL: ExitAction.DROP_INDIVIDUAL, FactsUnitFindingKind.EMPTY_VALUE: ExitAction.DROP_VALUE, FactsUnitFindingKind.NUMERIC_COVERAGE: ExitAction.REPORT, FactsUnitFindingKind.LABEL_ONLY_NUMBER: ExitAction.REPORT, FactsUnitFindingKind.SCALAR_AS_BOUNDS: ExitAction.REPORT, FactsUnitFindingKind.UNTYPED_INSTANCE: ExitAction.REPORT, FactsUnitFindingKind.MISSING_ROLE: ExitAction.REPORT, FactsUnitFindingKind.DIMENSION_CONFLICT: ExitAction.REPORT, FactsUnitFindingKind.DOMAIN_ADHERENCE: ExitAction.REPORT}
module-attribute
¶
EXIT_HANDLERS = {ExitAction.DROP_STATEMENTS: _drop_statements, ExitAction.DROP_LINK: _drop_link, ExitAction.DROP_TERM: _drop_term, ExitAction.DROP_TRIPLE: _drop_triple, ExitAction.DROP_INDIVIDUAL: _drop_individual, ExitAction.DROP_NUMBER: _drop_number, ExitAction.DROP_VALUE: _drop_empty_value, ExitAction.WRITE_BACK: _write_back}
module-attribute
¶
EXIT_REPAIR_KINDS = frozenset({FactsGateRepairKind.DOMAIN_VIOLATION_DROPPED, FactsGateRepairKind.ROLE_OUTSIDE_STATEMENT_DROPPED, FactsGateRepairKind.UNKNOWN_TERM_DROPPED, FactsGateRepairKind.UNGROUNDED_NUMBER_DROPPED, FactsGateRepairKind.VALUE_WITHOUT_NUMBER_DROPPED, FactsGateRepairKind.EMPTY_VALUE_DROPPED, FactsGateRepairKind.CONTRADICTED_INDIVIDUAL_DROPPED, FactsGateRepairKind.QUARANTINE_AS_COMMENT})
module-attribute
¶
ExitHandler = Callable[[_Exit, Sequence[FactsUnitFinding]], None]
module-attribute
¶
NOT_FINDINGS = frozenset({FactsUnitFindingKind.PROPERTY_ALIAS, FactsUnitFindingKind.CLOSED_RANGE_LITERAL, FactsUnitFindingKind.COMPACT_IRI_LITERAL, FactsUnitFindingKind.ENTAILED_TYPE, FactsUnitFindingKind.TRIPLE_REVERSED, FactsUnitFindingKind.CLASS_ALIAS, FactsUnitFindingKind.PAIRED_OBJECT_PROPERTY, FactsUnitFindingKind.CRITIC_FIX})
module-attribute
¶
__all__ = ['ABSENCE_KINDS', 'EXIT_ACTIONS', 'EXIT_HANDLERS', 'EXIT_REPAIR_KINDS', 'NOT_FINDINGS', 'ExitAction', 'UnitExit', 'exit_unit']
module-attribute
¶
Classes¶
ExitAction
¶
Bases: StrEnum
What leaving the loop does to the statements a finding names.
Source code in ontocast/stategraph/unit_exit.py
Attributes¶
DROP_INDIVIDUAL = 'drop_individual'
class-attribute
instance-attribute
¶
DROP_LINK = 'drop_link'
class-attribute
instance-attribute
¶
DROP_NUMBER = 'drop_number'
class-attribute
instance-attribute
¶
DROP_STATEMENTS = 'drop_statements'
class-attribute
instance-attribute
¶
DROP_TERM = 'drop_term'
class-attribute
instance-attribute
¶
DROP_TRIPLE = 'drop_triple'
class-attribute
instance-attribute
¶
DROP_VALUE = 'drop_value'
class-attribute
instance-attribute
¶
REPORT = 'report'
class-attribute
instance-attribute
¶
WRITE_BACK = 'write_back'
class-attribute
instance-attribute
¶
UnitExit
¶
Bases: BaseModel
What leaving the loop changed.
Attributes:
| Name | Type | Description |
|---|---|---|
records |
list[GraphRepairRecord]
|
One repair record per removal or write-back. |
quarantined |
list[RejectedLiteralTriple]
|
The unit's quarantined literals, those written back marked so. |
Source code in ontocast/stategraph/unit_exit.py
Functions:¶
exit_unit(graph, findings, quarantined, contract)
¶
Apply :data:EXIT_ACTIONS to the unit's unresolved findings.
Each mandatory finding goes to the handler of its kind's action
(:data:EXIT_HANDLERS), in the handlers' order: domain violations; a
statement's role link held by what is not a statement; every
use of a term an unknown_term finding names, in the position it names
-- a term a closed vocabulary does not have, a placeholder term, a class
or property minted in a facts namespace, a term outside a strict
vocabulary -- with the finding's suggested terms on its record, never
applied; literal type objects; contradicted individuals; ungrounded
numbers, a value whose numbers all went removed with the links to it;
values that state nothing, with the links to them; then literals still set aside go back on their subjects. Only mandatory
findings act: a warning stays in the graph and on the unit, and a kind
whose action is to report is carried to the document report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
RDFGraph
|
The unit's facts graph, mutated in place. |
required |
findings
|
Sequence[FactsUnitFinding]
|
The unit's findings after the gap pass. |
required |
quarantined
|
Sequence[RejectedLiteralTriple]
|
The unit's quarantined literals. |
required |
contract
|
StatementContract
|
The catalog's statement contract. |
required |