Namespacelib

The subpackage namespacelib provides popular namespace objects similar to the package rdflib. The classes are used as a simple way of using IRIs (Internationalized Resource Identifiers). By using the namespacelib subpackage, you can avoid having to write the full IRI each time you want to use a namespace and be sure that the IRI is correct.

The namespacelib subpackage is a simple way to use IRIs in your code. It is not a full ontology library and does not provide any reasoning capabilities. It is just a simple way to use IRIs in your code.

Available namespaces:

Examples

A popular way to describe units is to use the QUDT ontology. The following code shows how to use the QUDT namespace:

>>> from ontolutils.namespacelib import QUDT_UNIT
>>> QUDT_UNIT.M_PER_SEC
rdflib.term.URIRef('http://qudt.org/vocab/unit/M-PER-SEC')

Limitations

Some namespaces may be incomplete due to vocabularies with names that are reserved words in Python. E.g. the ontology schema.org contains “yield” and “True”, which are reserved words in Python. This means that the following code will raise an AttributeError:

from ontolutils import SCHEMA

SCHEMA.yield  # AttributeError: 'SCHEMA' object has no attribute 'yield'