I have a simple ontology file created using python and OWLReady, when I tried to do resoning with following code it shows
OwlReadyInconsistentOntologyError:
C:\ProgramData\Anaconda3\lib\site-packages\owlready2\reasoning.py in sync_reasoner_hermit(x, infer_property_values, debug, keep_tmp_file)
134 except subprocess.CalledProcessError as e:
135 if (e.returncode == 1) and (b"Inconsistent ontology" in (e.output or b"")):
--> 136 raise OwlReadyInconsistentOntologyError()
137 else:
138 raise OwlReadyJavaError("Java error message is:\n%s" % (e.stderr or e.output or b"").decode("utf8"))
OwlReadyInconsistentOntologyError:
this is ontology file I tried
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xml:base="http://elearn.org/onto.owl"
xmlns="http://elearn.org/onto.owl#">
<owl:Ontology rdf:about="http://elearn.org/onto.owl"/>
<owl:DatatypeProperty rdf:about="#Age">
<rdfs:domain rdf:resource="#Learner"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
</owl:DatatypeProperty>
<owl:DatatypeProperty rdf:about="#Name">
<rdfs:domain rdf:resource="#Learner"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
</owl:DatatypeProperty>
<owl:DatatypeProperty rdf:about="#Gender">
<rdfs:domain rdf:resource="#Learner"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
</owl:DatatypeProperty>
<owl:DatatypeProperty rdf:about="#Qualification">
<rdfs:domain rdf:resource="#Learner"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
</owl:DatatypeProperty>
<owl:DatatypeProperty rdf:about="#Branch">
<rdfs:domain rdf:resource="#Learner"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
</owl:DatatypeProperty>
<owl:DatatypeProperty rdf:about="#Background_Knowledge">
<rdfs:domain rdf:resource="#Learner"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
</owl:DatatypeProperty>
<owl:DatatypeProperty rdf:about="#Active_Reflective">
<rdfs:domain rdf:resource="#Learner"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
</owl:DatatypeProperty>
<owl:DatatypeProperty rdf:about="#AR_Value">
<rdfs:domain rdf:resource="#Learner"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
</owl:DatatypeProperty>
<owl:DatatypeProperty rdf:about="#Sensitive_Intutive">
<rdfs:domain rdf:resource="#Learner"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
</owl:DatatypeProperty>
<owl:DatatypeProperty rdf:about="#S_I_Value">
<rdfs:domain rdf:resource="#Learner"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
</owl:DatatypeProperty>
<owl:DatatypeProperty rdf:about="#Visual_Verbal">
<rdfs:domain rdf:resource="#Learner"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
</owl:DatatypeProperty>
<owl:DatatypeProperty rdf:about="#V_V_Value">
<rdfs:domain rdf:resource="#Learner"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
</owl:DatatypeProperty>
<owl:DatatypeProperty rdf:about="#Global_Sequential">
<rdfs:domain rdf:resource="#Learner"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
</owl:DatatypeProperty>
<owl:DatatypeProperty rdf:about="#G_S_Value">
<rdfs:domain rdf:resource="#Learner"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
</owl:DatatypeProperty>
<owl:Class rdf:about="#Learner">
<rdfs:subClassOf rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
</owl:Class>
<Learner rdf:about="#L1">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
<Age rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">18</Age>
<Name rdf:datatype="http://www.w3.org/2001/XMLSchema#string">L1</Name>
<Gender rdf:datatype="http://www.w3.org/2001/XMLSchema#string">M</Gender>
<Qualification rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">0</Qualification>
<Branch rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Mathematics with Computer</Branch>
<Background_Knowledge rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">0</Background_Knowledge>
<Active_Reflective rdf:datatype="http://www.w3.org/2001/XMLSchema#string">1</Active_Reflective>
<AR_Value rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">70</AR_Value>
<Sensitive_Intutive rdf:datatype="http://www.w3.org/2001/XMLSchema#string">0</Sensitive_Intutive>
<S_I_Value rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">40</S_I_Value>
<Visual_Verbal rdf:datatype="http://www.w3.org/2001/XMLSchema#string">1</Visual_Verbal>
<V_V_Value rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">60</V_V_Value>
<Global_Sequential rdf:datatype="http://www.w3.org/2001/XMLSchema#string">0</Global_Sequential>
<G_S_Value rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">50</G_S_Value>
</Learner>
</rdf:RDF>
This is the python code
from owlready2 import *
from rdflib.graph import Graph
world = World()
world.get_ontology("sample_ont.owl").load()
sync_reasoner(world)
graph = world.as_rdflib_graph()
I used this same code to open an another file (not the same ontology) which I created using Jena API , there were no error What is OwlReadyInconsistentOntologyError ? How can I solve this problem ?
It gives you this error because the Hermit reasoner has found that your ontology is inconsistent. This uses Artificial Intelligence reasoning procedures based on Description Logics to find logical errors in the statements of your ontology. Your other ontology did not give an error because it did not find any logical inconsistencies. You can check this yourself using Protege which you can download here.
If you open your ontology in Protege and run the Hermit reasoner, it will state that your ontology is inconsistent and it will provide reasons for the inconsistency. Here is a screenshot of the inconsistencies as displayed in Protege:
Looking at the first inconsistency it states
Global_Sequential Range: xsd:integer
L1 Global_Sequential "0" ^^xsd:string
The first line states that the Global_Sequential
data property has a range that is an xsd:integer
. This means that whenever an individual is linked to a value via the Global_Sequential
data property, that value is expected to be an integer.
The second line states that the the individual L1
is linked via the Global_Sequential
data property to a xsd:string
. This is why the ontology is inconsistent. That is for the individual Li
you should provide an integer value, not a string value.
For the individual L1
similar mistakes have been made for the data properties Active_Refelective
, Visual_Verbal
and Age
. In the case of Sensitive_Intuitive
the data property expects a string but an integer was provided.
Fixing all these values for the L1
individual will result in your ontology being consistent.