http://inferrences/ content ?

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

http://inferrences/ content ?

Fla
Hi,

I'm trying something simple :

my_onto = owl2.get_ontology(my_ontology).load()
with my_onto:
    owl2.sync_reasoner_pellet(infer_data_property_values=True,        infer_property_values=True,keep_tmp_file=0,debug=2)

    onto_infer = owl2.get_ontology("http://inferrences/")
    onto_infer.save("./onto_infer.nt",format="ntriples")

Question : why my file "onto_infer.nt" is empty ???
  ==> only one line in fact "<http://inferrences> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Ontology>"

Since my rules+ontology generates some inferences i can see with this code :

myobj=my_onto[key]
print("Showing <%s>"%(key))
for prop in myobj.get_properties():
    otype=prop.__bases__[0].python_name
    print("    ",prop.name,"= (",otype,") ",[item for item in getattr(myobj,prop.python_name)])

Where am i wrong ?
I've trying to understand reasoning.py code but i am a python newbie and there is a lot i don't understand...

Thank you very much !
Reply | Threaded
Open this post in threaded view
|

Re: http://inferrences/ content ?

Jiba
Administrator
Hi,

You called the reasoner INSIDE the "with my_onto:" block. Inside this block, all new RDF triples are added to the my_onto ontology. Consequently, nothing is inferred in the "http://inferrences/" ontology.

If you want to obtain the inference in "http://inferrences/", just remove the with block.

Jiba
Fla
Reply | Threaded
Open this post in threaded view
|

Re: http://inferrences/ content ?

Fla
Ok, newbie error :(
Many thanks for your answer Jiba.
Fla
Reply | Threaded
Open this post in threaded view
|

Re: http://inferrences/ content ?

Fla
In reply to this post by Jiba
Hello Jiba,


A new question about 'inferrences'

Here the code :
----------------------------------8<-------------------------------------------------
import sys

from owlready2 import *
onto = get_ontology("http://test.inferences/onto.owl#")

with onto:
    class Man(Thing):pass
    class hasFather(ObjectProperty, FunctionalProperty):
        domain = [Man]
        range = [Man]
    class hasSon(ObjectProperty,FunctionalProperty):
        domain = [Man]
        range = [Man]
    class isHappy(Man >> bool, FunctionalProperty): pass

pierre = Man("Pierre")
paul = Man("Paul",hasFather= pierre)

with onto:
    imp = Imp()
    imp.set_as_rule("Man(?x), hasFather(?x,?y) -> hasSon(?y,?x)")
    imp = Imp()
    imp.set_as_rule("Man(?x), hasSon(?x,?y) -> isHappy(?x,true)")

onto_infer = get_ontology("http://inferrences/")

sync_reasoner_pellet(infer_data_property_values=True, infer_property_values=True,keep_tmp_file = 0,debug=1)

onto.save('./my_onto_tests_after_reasonning.owl')
onto_infer.save('./my_onto_inferrences_after_reasoning.owl',format='rdfxml')

----------------------------------8<-------------------------------------------------


1) The reasoner output logs says :
[...]
* Owlready * Adding relation onto.Pierre hasSon onto.Paul
* Owlready * Adding relation onto.Pierre isHappy true
[...]

==> So i am expecting to found those two inferences  in 'onto' with other atoms and in 'into_infer'

In fact there is nothing in 'my_onto_inferrences_after_reasoning.owl' :-( and nothing about inferred axioms in 'my_onto_tests_after_reasonning.owl'

Could you tell me where i am wrong ?

Thank you very much,




Fla
Reply | Threaded
Open this post in threaded view
|

Re: http://inferrences/ content ?

Fla
Sorry !

« Protégé » do not show anything BUT the file 'my_onto_inferrences_after_reasoning.owl'
contains the the right stuff...

==> It's a  bug for Protégé not for Owlready2 ??

-------------------------------------------------8<--------------------------------------

<?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://inferrences/"
         xmlns:onto="http://test.inferences/onto.owl#"
         xmlns="http://inferrences/">

<owl:Ontology rdf:about="http://inferrences"/>

<rdf:Description rdf:about="http://test.inferences/onto.owl#Pierre">
  <onto:hasSon rdf:resource="http://test.inferences/onto.owl#Paul"/>
  <onto:isHappy rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</onto:isHappy>
</rdf:Description>


</rdf:RDF>