graflo.architecture.schema.semantics¶
Optional grounding of schema elements in external vocabularies.
Purely additive and never consulted at execution time: identity, storage naming and ingestion behave identically whether or not these blocks are present. Their audience is the reader — human or agent — deciding what a type means before deciding what to ask about it.
Serialized through the gf: meta-ontology, reusing rdfs:label and the SKOS
mapping and labelling properties rather than minting GraFlo-specific equivalents.
Attributes¶
VOCABULARY_PREFIXES = frozenset({'dc', 'dcat', 'dcterms', 'foaf', 'gf', 'owl', 'prov', 'qudt', 'rdf', 'rdfs', 'schema', 'sh', 'skos', 'sosa', 'ssn', 'xsd'})
module-attribute
¶
Classes¶
FieldSemantics
¶
Bases: Semantics
Anchors for a property, which additionally may carry a unit.
Separate from :class:Semantics on purpose: a unit on a vertex or an edge is
meaningless, and because these models forbid extra keys, the split makes
unit: on a vertex a validation error without any custom validator.
Source code in graflo/architecture/schema/semantics.py
Semantics
¶
Bases: ConfigBaseModel
External-vocabulary anchors for a vertex, edge, or whole schema.
Source code in graflo/architecture/schema/semantics.py
Attributes¶
broader = PydanticField(default_factory=list, description='IRIs of broader concepts in an external vocabulary (``skos:broader``).')
class-attribute
instance-attribute
¶
close_match = PydanticField(default_factory=list, description='IRIs of concepts close enough to interchange in some applications, but not asserted equivalent (``skos:closeMatch``).')
class-attribute
instance-attribute
¶
exact_match = PydanticField(default_factory=list, description='IRIs asserted equivalent to this element (``skos:exactMatch``).')
class-attribute
instance-attribute
¶
iri = PydanticField(default=None, description='IRI of the concept this element denotes, e.g. ``https://schema.org/Person``.')
class-attribute
instance-attribute
¶
label = PydanticField(default=None, description='Human-readable name of the element (``rdfs:label``).')
class-attribute
instance-attribute
¶
synonyms = PydanticField(default_factory=list, description='Alternative labels an agent may encounter (``skos:altLabel``).')
class-attribute
instance-attribute
¶
Functions:¶
check_iri(value, what)
¶
Return value, or raise when it is not an absolute IRI.
Source code in graflo/architecture/schema/semantics.py
iri_scheme(value)
¶
is_absolute_iri(value)
¶
Whether value is an absolute IRI: a scheme, a colon, and no whitespace.
A prefixed name over a well-known vocabulary (foaf:Agent) is not one:
the contract stores full IRIs only.
Source code in graflo/architecture/schema/semantics.py
merge_field_semantics(left, right, *, owner, field)
¶
Merge two property grounding blocks, refusing a unit clash.
The anchors fold exactly as :func:merge_semantics folds them. unit does
not: unlike a disputed iri, which costs the reader a claim about meaning,
two units mean the merged property would hold numerically incomparable
values -- the one place in this module where a disagreement is a defect in
the data rather than in its description.
Source code in graflo/architecture/schema/semantics.py
merge_semantics(left, right)
¶
Merge two semantic anchor blocks, unioning their anchors.
The list-valued anchors are sets of claims and simply union. iri is
single-valued and cannot: a type composed from one denoting
schema.org/Person and one denoting foaf:Agent denotes neither
exactly, so a disagreement clears it rather than silently electing the left
side's concept as the merged type's meaning. label folds the same way.
Source code in graflo/architecture/schema/semantics.py
union_anchors(values)
¶
Order-preserving de-duplication, for the list-valued anchor fields.