Posted by
Jacky on
URL: http://owlready.306.s1.nabble.com/How-to-do-twice-reasoning-tp1741.html
Hi, Thank you for developing OWLready. I tried twice reasoning, but I can not finish it. I just used the same example:
from owlready2 import *
import time
onto = get_ontology("
http://test.org/onto.owl")
with onto:
class Drug(Thing):
def take(self): print("I took a drug")
class ActivePrinciple(Thing):
pass
class has_for_active_principle(Drug >> ActivePrinciple):
python_name = "active_principles"
class Placebo(Drug):
equivalent_to = [Drug & Not(has_for_active_principle.some(ActivePrinciple))]
def take(self): print("I took a placebo")
class SingleActivePrincipleDrug(Drug):
equivalent_to = [Drug & has_for_active_principle.exactly(1, ActivePrinciple)]
def take(self): print("I took a drug with a single active principle")
class DrugAssociation(Drug):
equivalent_to = [Drug & has_for_active_principle.min(2, ActivePrinciple)]
def take(self): print("I took a drug with %s active principles" % len(self.active_principles))
acetaminophen = ActivePrinciple("acetaminophen")
amoxicillin = ActivePrinciple("amoxicillin")
clavulanic_acid = ActivePrinciple("clavulanic_acid")
test_acid = ActivePrinciple("test_acid")
AllDifferent([acetaminophen, amoxicillin, clavulanic_acid,test_acid])
drug1 = Drug(active_principles = [acetaminophen])
drug2 = Drug(active_principles = [amoxicillin, clavulanic_acid])
drug3 = Drug(active_principles = [])
close_world(Drug)
with onto:
sync_reasoner()
print('First reasoning:',drug1.__class__)
drug1.active_principles.append(test_acid)
close_world(Drug)with onto:
sync_reasoner()
print('second reasoning:',drug1.__class__)
I got the results as follows:
* Owlready2 * Warning: optimized Cython parser module 'owlready2_optimized' is not available, defaulting to slower Python implementation
* Owlready2 * Running HermiT...
java -Xmx2000M -cp E:\Work\test\venv\lib\site-packages\owlready2\hermit;E:\Work\test\venv\lib\site-packages\owlready2\hermit\HermiT.jar org.semanticweb.HermiT.cli.CommandLine -c -O -D -I file:///C:/Users/X/AppData/Local/Temp/tmpcx118ugk
First reasoning: onto.SingleActivePrincipleDrug
* Owlready2 * HermiT took 1.5297236442565918 seconds
* Owlready * Reparenting onto.drug2: {onto.Drug} => {onto.DrugAssociation}
* Owlready * Reparenting onto.drug1: {onto.Drug} => {onto.SingleActivePrincipleDrug}
* Owlready * Reparenting onto.drug3: {onto.Drug} => {onto.Placebo}
* Owlready * (NB: only changes on entities loaded in Python are shown, other changes are done but not listed)
* Owlready2 * Running HermiT...
java -Xmx2000M -cp E:\Work\test\venv\lib\site-packages\owlready2\hermit;E:\Work\test\venv\lib\site-packages\owlready2\hermit\HermiT.jar org.semanticweb.HermiT.cli.CommandLine -c -O -D -I file:///C:/Users/X/AppData/Local/Temp/tmp42ebyn1a
Traceback (most recent call last):
File "E:\Work\test\venv\lib\site-packages\owlready2\reasoning.py", line 134, in sync_reasoner_hermit
output = subprocess.check_output(command, stderr = subprocess.STDOUT)
File "C:\Users\X\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 395, in check_output
**kwargs).stdout
File "C:\Users\X\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 487, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['java', '-Xmx2000M', '-cp', 'E:\\Work\\test\\venv\\lib\\site-packages\\owlready2\\hermit;E:\\Work\\test\\venv\\lib\\site-packages\\owlready2\\hermit\\HermiT.jar', 'org.semanticweb.HermiT.cli.CommandLine', '-c', '-O', '-D', '-I', 'file:///C:/Users/X/AppData/Local/Temp/tmp42ebyn1a']' returned non-zero exit status 1.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:/Work/test/test7.py", line 50, in <module>
sync_reasoner()
File "E:\Work\test\venv\lib\site-packages\owlready2\reasoning.py", line 137, in sync_reasoner_hermit
raise OwlReadyInconsistentOntologyError()
owlready2.base.OwlReadyInconsistentOntologyError
Process finished with exit code 1.
I can not solve it. Could you help me if possible? Thanks in advance!