Hello
I'm new in ontology. I wrote the code given in documentation. the code is:
from owlready2 import *
onto = get_ontology("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")
AllDifferent([acetaminophen, amoxicillin, clavulanic_acid])
drug1 = Drug(active_principles = [acetaminophen])
drug2 = Drug(active_principles = [amoxicillin, clavulanic_acid])
drug3 = Drug(active_principles = [])
close_world(Drug)
sync_reasoner()
print("drug2 new Classes:", drug2.__class__)
drug1.take()
drug2.take()
drug3.take()
original code is here:
https://pythonhosted.org/Owlready2/reasoning.html#results-of-the-automatic-classificationbut the output is:
* Owlready2 * Warning: optimized Cython parser module 'owlready2_optimized' is not available, defaulting to slower Python implementation
* Owlready2 * Running HermiT...
java -Xmx2000M -cp /usr/local/lib/python3.5/dist-packages/owlready2/hermit:/usr/local/lib/python3.5/dist-packages/owlready2/hermit/HermiT.jar org.semanticweb.HermiT.cli.CommandLine -c -O -D -I file:////tmp/tmpvl0eenen
* Owlready2 * HermiT took 0.5114688873291016 seconds
* Owlready * (NB: only changes on entities loaded in Python are shown, other changes are done but not listed)
drug2 new Classes: onto.Drug
I took a drug
I took a drug
I took a drug
that is not the output given in documentation. what's wrong?
thank you.