This document will teach you how to load OWL into Grakn.
Edit me


This tutorial shows you how to migrate OWL into Grakn. If you have not yet set up the Grakn environment, please see the setup guide.

Migration Shell Script for OWL

The migration shell script can be found in /bin directory of your Grakn environment. We will illustrate its usage in an example below:

usage: graql migrate owl -input <arg> -keyspace <arg> [-help] [-uri <arg>] [-verbose]

 -c,--config <arg>     Configuration file.
 -h,--help             Print usage message.
 -i,--input <arg>      input csv file
 -k,--keyspace <arg>   Grakn knowledge base. Required.
 -u,--uri <arg>        Location of Grakn Engine.
 -v,--verbose          Print counts of migrated data.
 -d,--debug            Migration immediatly stops if any transaction fails

Please note: -no and -retry are not supported by OWL at the moment.

When you have read the following, you may find our extended example of OWL migration useful.

Example OWL migration

Consider the following OWL ontology:

<rdf:RDF xmlns=""

    <owl:Class rdf:about=""/>
    <owl:ObjectProperty rdf:about=""/>
    <owl:ObjectProperty rdf:about=""/>
    <owl:ObjectProperty rdf:about=""/>

    <owl:ObjectProperty rdf:about="">
        <owl:inverseOf rdf:resource=""/>
        <rdf:type rdf:resource=""/>
        <rdfs:domain rdf:resource=""/>
        <owl:propertyChainAxiom rdf:parseType="Collection">
             <rdf:Description rdf:about=""/>
             <rdf:Description rdf:about=""/>

    <owl:NamedIndividual rdf:about="#Witold">
        <rdf:type rdf:resource=""/>

    <owl:NamedIndividual rdf:about="#Stefan">
        <rdf:type rdf:resource=""/>
        <isParentOf rdf:resource="#Witold"/>

The schema defines a single class (type) Person as well as two instances of the class - individuals Witold and Stefan. The schema defines properties hasAncestor and its inverse isAncestorOf as well as hasParent and isParentOf properties. The hasAncestor property is defined as transitive and additionally defines a property chain which corresponds to the rule:

hasAncestor(X, Y) :- hasParent(X, Z), hasAncestor(Z, Y);

Upon migration, the OWL ontology will be mapped to Grakn. The resulting Graql statement, if printed out, looks as follows:

"tPerson" sub entity;

"owl-subject-op-isAncestorOf" sub role;
"owl-object-op-isAncestorOf" sub role;
"op-isAncestorOf" sub relationship, relates owl-subject-op-isAncestorOf, relates owl-object-op-isAncestorOf;
tPerson plays owl-subject-op-isAncestorOf, plays owl-object-op-isAncestorOf;

"owl-subject-op-hasAncestor" sub role;
"owl-object-op-hasAncestor" sub role;
"op-hasAncestor" sub relationship, relates owl-subject-op-hasAncestor, relates owl-object-op-hasAncestor;
tPerson plays owl-subject-op-hasAncestor, plays owl-object-op-hasAncestor;

"owl-subject-op-isParentOf" sub role;
"owl-object-op-isParentOf" sub role;
"op-isParentOf" sub relationship, relates owl-subject-op-isParentOf, relates owl-object-op-isParentOf;
tPerson plays owl-subject-op-isParentOf, plays owl-object-op-isParentOf;

"owl-subject-op-hasParent" sub role;
"owl-object-op-hasParent" sub role;
"op-hasParent" sub relationship, relates owl-subject-op-hasParent, relates owl-object-op-hasParent;
tPerson plays owl-subject-op-hasParent, plays owl-object-op-hasParent;

$eWitold isa tPerson;
$eStefan isa tPerson;
(owl-subject-op-isParentOf: $eStefan, owl-object-op-isParentOf: $eWitold) isa op-isParentOf;

inv-op-hasAncestor sub rule,
when {
(owl-subject-op-hasAncestor: $x, owl-object-op-hasAncestor: $y) isa hasAncestor;},
then {
(owl-subject-op-isAncestorOf: $y, owl-object-op-isAncestorOf: $x) isa isAncestorOf;};

inv-op-isAncestorOf sub rule,
when {
(owl-subject-op-isAncestorOf: $x, owl-object-op-isAncestorOf: $y) isa isAncestorOf;},
then {
(owl-subject-op-hasAncestor: $y, owl-object-op-hasAncestor: $x) isa hasAncestor;};

trst-op-hasAncestor sub rule,
when {
(owl-subject-op-hasParent: $x, owl-object-op-hasParent: $z) isa hasAncestor;
(owl-subject-op-hasAncestor: $z, owl-object-op-hasAncestor: $y) isa hasAncestor;},
then {
(owl-subject-op-hasAncestor: $x, owl-object-op-hasAncestor: $y) isa hasAncestor;};

pch-op-hasAncestor sub rule,
when {
(owl-subject-op-hasParent: $x, owl-object-op-hasParent: $z) isa hasParent;
(owl-subject-op-hasAncestor: $z, owl-object-op-hasAncestor: $y) isa hasAncestor;},
then {
(owl-subject-op-hasAncestor: $x, owl-object-op-hasAncestor: $y) isa hasAncestor;};

Where Next?

You can find further documentation about migration in our API reference documentation (which is in the docs directory of the distribution zip file, and also online here.

Please take a look at our examples to further illustrate OWL migration.

Tags: migration