ontocast.tool.facts_validation.statements¶
The statement model every facts rule reads.
A statement is an instance of a statement class: it is about something
else, and its links play roles (subject, property, result,
context). A value is a structured node a statement carries, blank or
named; its components are its numbers and the individuals it names.
:class:StatementContract is built once per catalog state by
:meth:~ontocast.tool.facts_validation.terms.CatalogRoles.statement_contract;
:func:value_components reads one value node through it. Neither names a
vocabulary term: the roles and classes come from the well-known registry and
the catalog.
Attributes¶
__all__ = ['RoleLinks', 'StatementContract', 'ValueComponent', 'ValueComponents', 'own_terms', 'value_components']
module-attribute
¶
Classes¶
RoleLinks
¶
Bases: BaseModel
The properties playing one statement role, closed over the catalog.
Attributes:
| Name | Type | Description |
|---|---|---|
forward |
frozenset[str]
|
Properties running from a statement. |
inverse |
frozenset[str]
|
Properties running to a statement. |
Source code in ontocast/tool/facts_validation/statements.py
StatementContract
¶
Bases: BaseModel
What the catalog says a statement and a value are.
Attributes:
| Name | Type | Description |
|---|---|---|
statement_classes |
dict[str, frozenset[StatementRoleName]]
|
Statement class -> the roles its instances must carry; every catalog class under a well-known statement class inherits that class's roles. |
required_links |
dict[str, frozenset[str]]
|
Statement class -> properties a catalog restriction
( |
value_classes |
frozenset[str]
|
Classes whose instances are values, with every catalog class under one. |
roles |
dict[StatementRoleName, RoleLinks]
|
Role -> its links (:meth: |
super_properties |
dict[str, frozenset[str]]
|
Property -> its catalog super-properties, for each property that has one. |
closed_ranges |
dict[str, frozenset[str]]
|
Property -> the classes of its range whose members are known (catalog individuals or a shipped term list). |
link_classes |
dict[str, frozenset[str]]
|
Role link -> the statement classes its declared side (domain from the statement, range to it) admits; a link absent here admits every class. |
anchor_links |
frozenset[str]
|
Properties declaring what a property node measures (a quantity kind, an applicable measurement unit), with every catalog sub-property of one. |
numeric_properties |
frozenset[str]
|
Properties whose declared datatype range (the catalog's or a well-known vocabulary's) is numeric. |
property_classes |
frozenset[str]
|
Classes whose instances a statement's |
Source code in ontocast/tool/facts_validation/statements.py
Attributes¶
anchor_links = frozenset()
class-attribute
instance-attribute
¶
closed_ranges = Field(default_factory=dict)
class-attribute
instance-attribute
¶
link_classes = Field(default_factory=dict)
class-attribute
instance-attribute
¶
model_config = ConfigDict(frozen=True)
class-attribute
instance-attribute
¶
numeric_properties = frozenset()
class-attribute
instance-attribute
¶
property_classes = frozenset()
class-attribute
instance-attribute
¶
required_links = Field(default_factory=dict)
class-attribute
instance-attribute
¶
roles = Field(default_factory=dict)
class-attribute
instance-attribute
¶
statement_classes = Field(default_factory=dict)
class-attribute
instance-attribute
¶
super_properties = Field(default_factory=dict)
class-attribute
instance-attribute
¶
value_classes = frozenset()
class-attribute
instance-attribute
¶
Methods:¶
is_statement(types)
¶
is_value(types)
¶
links(role)
¶
properties_of(prop)
¶
required_roles(types)
¶
The roles an instance of types must carry.
Source code in ontocast/tool/facts_validation/statements.py
serves(link, types)
¶
Whether link can play its role for an instance of types.
It can when its declared side admits one of the types; a link with no declared side admits every type.
Source code in ontocast/tool/facts_validation/statements.py
ValueComponent
¶
Bases: BaseModel
One non-annotation triple of a value node.
Attributes:
| Name | Type | Description |
|---|---|---|
predicate |
str
|
The property it is written on. |
properties |
frozenset[str]
|
|
value |
Literal | URIRef
|
The literal or the IRI. |
number |
str | None
|
The canonical decimal form of a numeric literal, else |
closed_range |
frozenset[str]
|
For an individual, the classes of the property's range whose members are known; empty for a number or an open range. |
Source code in ontocast/tool/facts_validation/statements.py
Attributes¶
closed_range = frozenset()
class-attribute
instance-attribute
¶
model_config = ConfigDict(frozen=True, arbitrary_types_allowed=True)
class-attribute
instance-attribute
¶
number = None
class-attribute
instance-attribute
¶
predicate
instance-attribute
¶
properties
instance-attribute
¶
value
instance-attribute
¶
Methods:¶
on(properties)
¶
Whether the component is written on one of properties or under one.
ValueComponents
¶
Bases: BaseModel
The numbers and the individuals of a value node, and its other literals.
Attributes:
| Name | Type | Description |
|---|---|---|
numbers |
tuple[ValueComponent, ...]
|
Numeric literals, by predicate and value. |
individuals |
tuple[ValueComponent, ...]
|
IRIs it names, by predicate and value. |
texts |
tuple[ValueComponent, ...]
|
Its other non-annotation literals (text, dates), by predicate and value: no component, but a value stating another one on a property is another value. |
Source code in ontocast/tool/facts_validation/statements.py
Attributes¶
individuals = ()
class-attribute
instance-attribute
¶
model_config = ConfigDict(frozen=True)
class-attribute
instance-attribute
¶
numbers = ()
class-attribute
instance-attribute
¶
texts = ()
class-attribute
instance-attribute
¶
Methods:¶
numbers_on(properties)
¶
The numbers written on properties or a sub-property of one.
Functions:¶
own_terms(graph, terms)
¶
The terms that graph names and no well-known vocabulary owns, sorted.
Read over a unit's ontology context: the catalog's own terms in it.
Source code in ontocast/tool/facts_validation/statements.py
value_components(graph, node, contract)
¶
The numbers and individuals node states, blank or named, and its texts.
A component is a triple of node that is not a type, an alias or an
annotation (:func:~ontocast.onto.annotation.is_annotation): a number or
an individual (an IRI). A literal is a number when it is typed numeric, or
untyped with a numeric form on a property whose declared range is numeric
(:attr:StatementContract.numeric_properties): a digit string elsewhere
is text, such as an identifier. Text and dates are kept apart as
texts; nested blank nodes are none of these. Ordered by predicate and
value.