ontometer_corpus.roles¶
Term roles: whether each IRI is used as a class or as an instance in a file.
The TBox/ABox split is binary inside one well-formed OWL file, but across a corpus the same IRI is a class here, an individual there, and sometimes both in one file (OWL 2 punning). Recording, per file, which roles each term plays lets class-likeness be measured as a share of documents rather than asserted.
Roles, with the sense each supports:
================= ========= ===============================================
role sense evidence in the file
================= ========= ===============================================
decl_class class typed owl:Class or rdfs:Class
sub_child class subject of a named rdfs:subClassOf
sub_parent class object of a named rdfs:subClassOf
has_instance class object of rdf:type (something is typed by it)
axiom_ref class domain/range, restriction filler, equivalence,
disjointness or complement operand
decl_individual instance typed owl:NamedIndividual
typed instance subject of rdf:type with a non-meta type
or owl:Thing
skos_concept marker directly typed skos:Concept; retained so
namespace ownership uses concept-local evidence
fact_subj instance subject of a fact (see below)
fact_obj instance object of a fact
================= ========= ===============================================
A fact is a triple between two IRIs whose predicate is not a language term
(RDF, RDFS, OWL, ...) and which :class:ontometer_corpus.usage.UsageContext
reads as a property assertion rather than an annotation: not about the
ontology header or an axiom annotation, not through a property the file
declares owl:AnnotationProperty, and, for a predicate the file never
declares, not about a declared class or property (OWL 2 DL allows only
annotations there). No vocabulary is excluded by name: dcterms:creator on
the header is metadata, between two individuals it is a fact. Without these
exclusions, metadata would make ordinary classes look like instances.
Attributes¶
CLASS_ROLES = frozenset({'decl_class', 'sub_child', 'sub_parent', 'has_instance', 'axiom_ref'})
module-attribute
¶
INSTANCE_ROLES = frozenset({'decl_individual', 'typed', 'fact_subj', 'fact_obj'})
module-attribute
¶
META_NAMESPACES = tuple(sorted(LANGUAGE_NAMESPACES))
module-attribute
¶
Classes¶
Functions:¶
is_meta(iri)
¶
Whether iri lies in one of :data:META_NAMESPACES (modelling language or tooling).
Such terms are never recorded as domain terms and never count as ends of a specialisation.
Source code in ontometer_corpus/roles.py
roles_from_graph(graph)
¶
Roles and preferred labels of every domain IRI in one parsed file.
Returns:
| Type | Description |
|---|---|
dict[str, set[str]]
|
|
dict[str, str]
|
plays; |
Source code in ontometer_corpus/roles.py
obo_to_iri(obo_id, ontology_name)
¶
The OBO-id to IRI expansion the corpus parser uses.
Source code in ontometer_corpus/roles.py
roles_from_obo(text, fallback_name=None)
¶
Roles and name: labels from an OBO flat file.
[Term] stanzas are classes; is_a, relationship and the
class-expression tags reference classes; [Instance] stanzas are
individuals, typed by instance_of and linked by property_value.
[Typedef] stanzas declare properties and play no role here.
Source code in ontometer_corpus/roles.py
summarise(roles)
¶
iri -> (plays a class role, plays an instance role).
kb_individuals(individual_count, skos_concept_count=None)
¶
Individuals that make a source knowledge-base-like: SKOS concepts excluded.
The corpus' individual_count follows the RDF semantics, in which a
skos:Concept is an individual. A concept scheme's concepts are its
vocabulary rather than facts about a domain, so for the ontology versus
knowledge-base split they count as terms. Missing counts read as zero; a
missing skos_concept_count column (rows parsed before it existed)
subtracts nothing.