Chapter 5. Importing Ontologies

Ontologies are serialised as RDF, so they can be imported using plain importRDF but the liteOntoImport method will give us a higher level of control over how an RDFS or OWL ontology is imported into Neo4j. It’s important to note that this procedure exclusively import the following:

  1. Named class (category) declarations with both rdfs:Class and owl:Class.
  2. Explicit class hierarchies defined with rdf:subClassOf statements.
  3. Property definitions with owl:ObjectProperty, owl:DatatypeProperty and rdfs:Property
  4. Explicit property hierarchies defined with rdfs:subPropertyOf statements.
  5. Domain and range information for properties described as rdfs:domain and rdfs:range statements.

All other elments will be ignored by this loader.

The liteOntoImport procedure takes the same generic params described in ??? at the beginning of the Chapter 3, Importing RDF data section, so we will invoke it with a URL and a serialisation format. In the following example we will import the ontology in this file.

CALL semantics.importOntology("http://jbarrasa.github.io/neosemantics/docs/rdf/vw.owl","Turtle")
VW ontology imported in Neo4j

As we see in the ingested graph, by default, classes will be persissted as nodes with label Class with two properties: uri and name and rdf:subClassOf statements are stored ass relationships of type SCO between Class nodes. Similarly, relationships will be persisted as nodes with name and uri and labels Relationship or Property for owl:ObjectProperty and owl:DatatypeProperty respectively. Statements with rdf:subPropertyOf as predicate are stored as relationships of type SPO between Relationship or Property nodes.

These graph model elements can be overriden by using the following configuration params:

Here’s an example of how to load an ontology using some of these parameters:

CALL semantics.importOntology("http://jbarrasa.github.io/neosemantics/docs/rdf/vw.owl","Turtle", { classLabel : 'Category', objectPropertyLabel: 'Rel', dataTypePropertyLabel: 'Prop'})

Finally, it’s also possible to have imported nodes (both Classes and Properties/Relationships) labeled as Resource for compatibility with the importRDF procedure. This is done by setting the addResourceLabels parameter to true.