Extending the ontology by adding rules

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

Extending the ontology by adding rules

IWilliams
I am aware that Owlready does not support SWRL yet, but is there a do rule base reason in owlready? This way Hermit can infer new relations based on the rules in the ontology.
Reply | Threaded
Open this post in threaded view
|

Re: Extending the ontology by adding rules

Jiba
Administrator
As said in the following topic, the problem is that HermiT does not export all inferrence performed through rules (although some may be exported). Takeing those inferrence into account requires to modify the source of HermiT, which is quite complex (although doable).

http://owlready.8326.n8.nabble.com/Accessing-inferred-facts-in-individuals-tp503.html
Reply | Threaded
Open this post in threaded view
|

Re: Extending the ontology by adding rules

Mareike
Hi, I am using the Pellet reasoner because HermiT complains that some rules use built-in atoms which aren't supported yet (I defined SWRL rules that create new object and data properties for my instances). Is this the same issue, or is it easier to access the inference result from the Pellet reasoner? I tried to dig into the debug output, but I am struggling to interpret it as it does not seem to output those instances that should be altered but rather a formatted full list of classes and instances in my OWL file? In Protege, the rules work fine and produce the expected result. Will the results be accessible through owlready2 at some point, or do I have to find another way? The stored tmp file created during the reasoning process didn't help much either..

Best,
Mareike
Reply | Threaded
Open this post in threaded view
|

Re: Extending the ontology by adding rules

Jiba
Administrator
Hi,

I've tested some simple rules (see file below) with both HermiT and Pellet, and the inferences are properly obtained in Owlready (using the development version). The development version of Owlready also supports inferrence on property values (which may be done via SWRL rules).

https://bitbucket.org/jibalamy/owlready2/src/default/test/test_rule.owl

Best regards,
Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Extending the ontology by adding rules

Mareike
Hey, thank you for the answer and the test file. To me it looks like I am doing something wrong when using owlready, as I have the same problem with your file. I can see the inference results in protege, but using owlready I can't access the inferred results. So maybe you can help me out here? What I do is:

I import owlready like this (I got this from some other forum entry):
import owlready2
from owlready2 import *

then I load the ontology:

onto = get_ontology(path-to-my-owl-file)
onto.load()

and call the reasoner by calling

sync_reasoner_pellet(debug=9)

Everything looks fine so far, as it does not produce errors. But the output already indicates that the properties are ignored i.e. there is nothing shown that makes me think it inferred any kind of property, while it does show this, indicating that your rules are at least not completely ignored.

* Owlready * Reparenting test_rule.e: {test_rule.E} => {test_rule.E, test_rule.S}

So what I would expect is that calling

onto.search_one(iri='*e').get_properties()

would give me a set containing the data property 'data_prop' and the object property 'prop' which is linked to obj, but it returns an empty set.
So I read, that the inference results are stored somewhere else (in http://inferrences/), but I don't know how to access it.
I tried to load it with get_ontology and executed the same query, but of course that did not work.
So maybe I simply have wrong expectations about my queries? Or how would I programmatically access the inferred information, that the individual 'e' now has a 'prop'='obj' and a 'data_prop'='true'?

Thanks,
Mareike
Reply | Threaded
Open this post in threaded view
|

Re: Extending the ontology by adding rules

Jiba
Administrator
Hi,

Mareike wrote
and call the reasoner by calling

sync_reasoner_pellet(debug=9)
You need to add the infer_property_values parameter:

sync_reasoner_pellet(infer_property_values = True, debug = 9)

Best regards,
Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Extending the ontology by adding rules

Mareike
Hi,
thanks a lot, that helped. I can now properly infer property values from your owl file as well as my own. If I get that right, the current version only support the property values but not the data values, is that correct? I can imagine that inferring data values is a lot of effort, but is this currently under development?

-Mareike
Reply | Threaded
Open this post in threaded view
|

Re: Extending the ontology by adding rules

Jiba
Administrator
Hi,

Actually, I'm not sure inference on property data is implemented in reasoner. In fact, in Protégé, I've tried them but inferred values for data properties are not displayed.

Inferring values of data properties would be nice, but it seems even more complex than for object properties.

Best regards,
Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Extending the ontology by adding rules

Mareike
Hi,
in Hermit it doesn't work for me, as my SWRL rules contain built-in atoms (https://bitbucket.org/mareikep/materials-owl/src/master/materialsexample.owl), but Pellet works fine. In Protege, I can see both inferred properties (object and data) for the two individuals 100Cr13 and DistAB (the two swrl rules are supposed to determine the base unit of a given property and calculate the respective value for it, e.g. 1 kilometer = 1000 meters). But maybe I should mention, that I ticked everything under Reasoner -> Configure -> Displayed Inferences. However, if I find the time, I might have a look into the data property reasoning myself some time, but will nevertheless follow the developments in owlready2, hoping, that someone else does it ;)
Thanks!

-Mareike
Reply | Threaded
Open this post in threaded view
|

Re: Extending the ontology by adding rules

Jiba
Administrator
Hi,

You're right, it works with Pellet after configuring Protégé.
I think it will not be difficult to implement in Owlready, I'll look at it soon.

Best regards,
Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Extending the ontology by adding rules

Jiba
Administrator
Hi,

The development version of Owlready now support inferrence on data property values with Pellet. The reasoner must be called as follows:

    sync_reasoner_pellet(infer_property_values = True, infer_data_property_values = True)

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Extending the ontology by adding rules

Mareike
Uuuuh, nice, I'll check it out!
Thanks!

-Mareike