HermiT does not work properly

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

HermiT does not work properly

cy83rc0llect0r
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-classification

but 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.
Reply | Threaded
Open this post in threaded view
|

Re: HermiT does not work properly

Jiba
Administrator
Hello,

The problem is at the beginning : if you create a new ontology, you need to specify its full IRI, for example :

>>> onto = get_ontology("http://test.org/onto.owl")

and not just "onto.owl". You can use a local filename only if you load the ontology (in that case, the full IRI will be found in the ontology file).

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: HermiT does not work properly

cy83rc0llect0r
Thank you Jiba. I uploaded the ontology to a server and put its address to get_ontology as a argument and it worked.
Thank you.
Reply | Threaded
Open this post in threaded view
|

Re: HermiT does not work properly

Jiba
Administrator
Notice that you DO NOT NEED to have the ontology available online at its IRI. You can run the example as-in, even if the ontology URL does not exist.

Jiba