ontoenv
WebsiteOntoEnv
OntoEnv is a simple tool for managing a collection of ontology definitions (instances of owl:Ontology
) and dependencies (owl:imports
statements). This is functionality that is often provided by modeling IDEs such as Protégé and TopBraid Composer, but seems currently lacking in the Python/RDFlib ecosystem. Once initialized in a directory, OntoEnv will search for all RDF files and resolve their owl:imports
statements, downloading remote files or resolving from local definitions as needed.
OntoEnv provides Python bindings which will import the ontology definitions for all owl:imports
statements into an rdflib.Graph
.
Typical Usage
Typical usage looks as follows.
First, tell OntoEnv to figure out the dependency graph and cache the ontology/graph definitions.
$ ontoenv init # resolving imports can take a few seconds, depending on the number of dependencies
$ ontoenv refresh # run 'refresh' if any dependencies change
Then, use the Python bindings to import ontology definitions into a graph
import rdflib
import ontoenv
# initialize environment
env = ontoenv.OntoEnv()
g = rdflib.Graph()
g.parse("my_graph.ttl", format="ttl")
env.import_dependencies(g)
Other commands:
dump
: print the locations of all URIs known byontoenv
Installation
pip install ontoenv
Details
An RDF graph can be associated with a URI by including a statement in the graph that the URI is an instance of owl:Ontology
.
@prefix owl: .
a owl:Ontology .
# ... other triples
Other RDF graphs can import the contents of http://example.com/my/graph
in their own owl:Ontology
definitions:
@prefix owl: .
a owl:Ontology ;
owl:imports .
OntoEnv has the option of transitively resolving these dependencies.