ontocast.tool.agg.statement_conflict¶
Identity read from statements: when two things are distinct, when two values are one.
A statement reports a property of a subject with a result, possibly in a
context (a time, a condition, a procedure). The same property of one thing,
in one context, has one result; so two subjects whose statements report one
property with conflicting results and no differing context link are two
things. :func:statement_conflict is that test. The aggregator asks it about
a candidate pair; the facts gate asks it about one node and itself, where a
conflict means two things were merged into one.
A statement is also indexed under itself, so two statements reporting one property with conflicting results stay two statements.
Two property nodes are distinct when the results reported for them disagree
in dimension: :func:dimension_conflict. A result's dimension is that of the
measurement units it names (:func:value_dimensions, from the well-known
registry); a result with no unit, or a unit of no known dimension, has none
and decides nothing. :func:dimension_conflicts reads the same signal within
one graph: results reported for one property node, or by one statement, that
disagree in dimension. Dimensionless quantities share one dimension, so a
ratio, an angle and a percentage never disagree.
:func:values_conflict says when two values state something differently (another
number on one slot, another measurement unit); :func:values_agree when they
are one value: they share a number and nothing both state differs.
Roles come from the :class:~ontocast.tool.facts_validation.statements.StatementContract;
no vocabulary term is named here.
Attributes¶
Same = Callable[[Node, Node], bool]
module-attribute
¶
__all__ = ['DimensionConflict', 'Same', 'StatementIndex', 'StatementRecord', 'dimension_conflict', 'dimension_conflict_findings', 'dimension_conflict_message', 'dimension_conflicts', 'property_anchor', 'statement_conflict', 'statement_conflict_findings', 'value_dimensions', 'values_agree', 'values_conflict']
module-attribute
¶
Classes¶
DimensionConflict
¶
Bases: BaseModel
Results that disagree in dimension, within one graph.
Attributes:
| Name | Type | Description |
|---|---|---|
node |
Node
|
The property node the results are reported for, or the statement whose results they are. |
by_property |
bool
|
Whether |
dimensions |
frozenset[str]
|
The dimensions of the results, as IRIs. |
anchored |
bool
|
Whether the catalog declares what the property measures (a
quantity kind or an applicable measurement unit,
:func: |
anchor |
frozenset[str]
|
The dimensions that declaration names; empty when it names none of a known dimension. |
odd |
tuple[Node, ...]
|
The statements whose results disagree with |
Source code in ontocast/tool/agg/statement_conflict.py
Attributes¶
anchor = frozenset()
class-attribute
instance-attribute
¶
anchored
instance-attribute
¶
by_property
instance-attribute
¶
dimensions
instance-attribute
¶
model_config = ConfigDict(frozen=True, arbitrary_types_allowed=True)
class-attribute
instance-attribute
¶
node
instance-attribute
¶
odd = ()
class-attribute
instance-attribute
¶
StatementIndex
¶
The statements of some graphs, by the subjects they are about and by the property nodes they report.
Build with :meth:of; the graphs must not change while it is in use.
Source code in ontocast/tool/agg/statement_conflict.py
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 | |
Methods:¶
__init__(by_subject, by_property=None, statements=None)
¶
Source code in ontocast/tool/agg/statement_conflict.py
about(node)
¶
dimensions_of(prop)
¶
The dimensions of the results reported for prop
(:func:value_dimensions); empty when none has a known one.
Source code in ontocast/tool/agg/statement_conflict.py
of(graphs, contract)
classmethod
¶
Index every statement of graphs under its subjects and itself,
and under each property node it reports.
Each graph is read on its own: a blank result belongs to the graph that wrote it.
Source code in ontocast/tool/agg/statement_conflict.py
properties()
¶
reporting(prop)
¶
statements()
¶
StatementRecord
¶
Bases: BaseModel
One statement, as the identity checks read it.
Attributes:
| Name | Type | Description |
|---|---|---|
statement |
Node
|
The statement node. |
properties |
frozenset[Node]
|
The property nodes it reports. |
results |
tuple[ValueComponents, ...]
|
Its results that hold a number, each as its components; a literal result is one number that fits any slot. |
context |
frozenset[tuple[str, Node | tuple[tuple[str, str], ...]]]
|
Its context links, as |
Source code in ontocast/tool/agg/statement_conflict.py
Functions:¶
dimension_conflict(index, left, right)
¶
Whether the results reported for the property nodes left and
right disagree in dimension.
They disagree when both have results of a known dimension
(:meth:StatementIndex.dimensions_of) and no dimension is common to the
two. Inert when either has none: a value without a measurement unit, or
with a unit of no known dimension, decides nothing.
Returns:
| Type | Description |
|---|---|
tuple[frozenset[str], frozenset[str]] | None
|
The dimensions of |
Source code in ontocast/tool/agg/statement_conflict.py
dimension_conflict_findings(graph, ontology_graph, fact_namespaces, document=None)
¶
One warning per :class:DimensionConflict of the aggregated graph.
Anchored or not: a conflict a unit could not resolve, and one between results that several units wrote, are both served.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
Graph
|
The aggregated facts graph. |
required |
ontology_graph
|
RDFGraph | None
|
The ontology context, for the catalog's role links and anchors. |
required |
fact_namespaces
|
list[str]
|
Namespaces of the fact instances. |
required |
document
|
Node | None
|
The document node, never read as a statement's subject. |
None
|
Source code in ontocast/tool/agg/statement_conflict.py
dimension_conflict_message(conflict)
¶
What a :class:DimensionConflict says, for a finding.
Source code in ontocast/tool/agg/statement_conflict.py
dimension_conflicts(index, catalog, contract)
¶
Results that disagree in dimension: those reported for one property node, then those of one statement not already counted.
Results under an anchored property (:func:property_anchor) whose anchor
has known dimensions disagree when one shares none of them; that
statement is the odd one. Otherwise they disagree when two results share
no dimension. A result without a measurement unit, or with one of no known
dimension, decides nothing, and so does a dimensionless one against
another dimensionless one.
Source code in ontocast/tool/agg/statement_conflict.py
property_anchor(catalog, contract, prop)
¶
Whether the catalog declares what prop measures, and its dimensions.
The declaration is a link of the contract's anchor_links from
prop: a measurement unit, whose dimension is the registry's, or a
quantity kind, whose dimensions are those of the measurement units the
catalog links from it the same way.
Returns:
| Type | Description |
|---|---|
bool
|
Whether |
frozenset[str]
|
when none is of a known dimension). |
Source code in ontocast/tool/agg/statement_conflict.py
statement_conflict(index, left, right, same=_identical)
¶
The property on which statements show left and right distinct.
Two statements, one about each (or two about one node when left is
right), conflict when they report one property, every result of one
conflicts with every result of the other (:func:values_conflict), and no
context link of one is absent from or other in the other: a time series
is not a conflict. Statements that are one (same) are never compared.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
StatementIndex
|
The statements to read. |
required |
left
|
Node
|
One node. |
required |
right
|
Node
|
The other node, or |
required |
same
|
Same
|
Whether two nodes denote one thing. |
_identical
|
Returns:
| Type | Description |
|---|---|
Node | None
|
The reported property of the first conflict found, or |
Source code in ontocast/tool/agg/statement_conflict.py
statement_conflict_findings(graph, ontology_graph, fact_namespaces, document=None)
¶
One warning per fact node that :func:statement_conflict shows distinct
from itself.
Aggregation vetoes every merge that would produce one, so on a served graph the list is empty; a finding is a merge that slipped through, or one content unit stating one property twice with conflicting results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
Graph
|
The aggregated facts graph. |
required |
ontology_graph
|
RDFGraph | None
|
The ontology context, for the catalog's role links. |
required |
fact_namespaces
|
list[str]
|
Namespaces of the fact instances reported. |
required |
document
|
Node | None
|
The document node, never reported. |
None
|
Source code in ontocast/tool/agg/statement_conflict.py
value_dimensions(components)
¶
The dimensions of the measurement units a value names, as IRIs.
Empty when it names no individual of a known dimension.
Source code in ontocast/tool/agg/statement_conflict.py
values_agree(left, right, same=_identical)
¶
Whether two values are one: they share a number, no component both
state differs (:func:values_conflict), and no property both state text
or a date on holds other text in one.
An estimate and its interval share no number and are two values; one number with two different measurement units, or in two currencies written as text, is two values.
Source code in ontocast/tool/agg/statement_conflict.py
values_conflict(left, right, same=_identical)
¶
Whether a component both values state differs: another number on one slot, another individual (a measurement unit) on one property.
An estimate and its interval state nothing in common and do not conflict.