ontometer_corpus.namespaces¶
Namespace rules: which namespace an IRI belongs to, and which no ontology can own.
Coupling — how much of an ontology's vocabulary it borrows rather than declares — depends on these rules, so every coupling measure reads this one definition. The module needs only the standard library, so any package that measures coupling the same way can import it without the rest of the corpus stack.
:data:LANGUAGE_NAMESPACES is the one closed list: the namespaces of RDF, OWL and
the other representation languages. Popular vocabularies are not listed as
"generic"; how a file uses them is measured instead.
Attributes¶
OBO_BASE_NS = 'http://purl.obolibrary.org/obo/'
module-attribute
¶
LANGUAGE_NAMESPACES = frozenset({'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'http://www.w3.org/2000/01/rdf-schema#', 'http://www.w3.org/2001/XMLSchema#', 'http://www.w3.org/XML/1998/namespace', 'http://www.w3.org/2002/07/owl#', 'http://www.w3.org/2003/11/swrl#', 'http://www.w3.org/2003/11/swrlb#', 'http://swrl.stanford.edu/ontologies/3.3/swrla.owl#', 'urn:swrl#', 'urn:swrl:var#', 'http://www.geneontology.org/formats/oboInOwl#', 'http://protege.stanford.edu/plugins/owl/protege#'})
module-attribute
¶
UNOWNABLE_NAMESPACES = LANGUAGE_NAMESPACES | {OBO_BASE_NS}
module-attribute
¶
Functions:¶
reference_kind(reference_iri)
¶
Coarse research role of a referenced namespace or IRI.
language for the representation languages (:data:LANGUAGE_NAMESPACES),
metadata_or_identifier for identifier and web-reference namespaces,
malformed_or_local for strings that are not resolvable namespaces
(including the bare OBO PURL root, which only arises from malformed OBO
local names), else domain_vocabulary. A namespace alone cannot say
whether a file uses it for modelling or for metadata; that is measured per
use by :mod:ontometer_corpus.usage.
Source code in ontometer_corpus/namespaces.py
iri_namespace(iri)
¶
Return an IRI's namespace prefix.
Everything up to and including the last # or, failing that, the last
/. Returns None for empty input or a string with neither delimiter,
which is not a hierarchical IRI.
Special case: under the generic OBO Foundry path, a well-formed
PREFIX_localid local name (GO_0008150, CHEBI_36357) yields
.../obo/PREFIX_ rather than the bare .../obo/, so that OBO
ontologies are distinguishable from one another. Malformed or non-standard
local names fall back to the bare generic path.