Using SWRL Rules / Different Reasoner

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

Using SWRL Rules / Different Reasoner

martingrant
Hello I am looking to use SWRL rules to work on individual instances of classes, particularly looking to compare values using swrlb:lessThan and so on. These functions are not supported by the Hermit reasoner, but are by e.g. Pellet. Is there anyway I can use Owlready with a different reasoner or can you suggest some other mechanism I can use to compare data properties of class individuals? Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Using SWRL Rules / Different Reasoner

Jiba
Administrator
Hello,

I added support for Pellet in the development version of Owlready (on Bitbucket) a few days ago. It is fully working but still needs testing.

You simply use sync_reasoner_pellet() instead of sync_reasoner().

Best regards,
Jean-Baptiste Lamy
Reply | Threaded
Open this post in threaded view
|

Re: Using SWRL Rules / Different Reasoner

martingrant
Hi Jiba thanks for your quick response. That looks promising. I'm using Owlready installed using pip, how am I able to get access to the development version?

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Using SWRL Rules / Different Reasoner

martingrant
I think I have got the development branch working where I can call the sync_reasoner_pellet() function. I have came across a new problem where I see in the forums you have said else where that Owlready does not support rules on individuals unfortunately. I was hoping to be able to run rules on individuals during the execution of a program.
Reply | Threaded
Open this post in threaded view
|

Re: Using SWRL Rules / Different Reasoner

Jiba
Administrator
It depends on the results of the rule: if it classifies the individual in a new class, it should be Ok. However, if it add some new relation to the individual, it won't appear in Owlready unless Pellet is modified to show these new relations on command-line.
Reply | Threaded
Open this post in threaded view
|

Re: Using SWRL Rules / Different Reasoner

martingrant
Yes my rule is trying to add a new relation between different individuals. It looks like:

hasPositionX(?a, ?p1) ^ hasPositionX(?b, ?p2) ^ swrlb:lessThan(?p1, ?p2) -> isLeftOf(?a, ?b)

I'm trying to create an ontology about the spatial properties of objects.
Reply | Threaded
Open this post in threaded view
|

Re: Using SWRL Rules / Different Reasoner

martingrant
In reply to this post by Jiba
Hi Jiba,

I wonder if you could tell me if it would be quite involved and a complex task to modify Pellet in order to achieve the mechanic of applying a new relation to an individual from an SWRL rule?

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Using SWRL Rules / Different Reasoner

Jiba
Administrator
Hi,

It's difficult to give a clear answer: it depends a lot on how it is difficult in Pellet (and also on your Java skills). The difficulty is to obtain the deduced relations and to print them on the standard output. Then, parsing them in Python and applying them in Owlready is easy.

HermiT may also be able to deduced relation (not sure), and it may be easier or harder to exploit them.

Probably the best way to answer the question is to try?

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

Re: Using SWRL Rules / Different Reasoner

ai_coder_42
Hi,

I came across this thread since I want to use newly inferred object_properties derived from using Pellet with an ontology containing SWRL rules.

I was poking through the source code and wondered if changing the 'realize' argument of the pellet call (line 228 of reasoning.py - https://bitbucket.org/jibalamy/owlready2/src/default/reasoning.py) to 'extract' instead, and then just load that in somehow? (I haven't looked into how this could be done all within owlready2).

For what I'm using right now, I'm planning to do the following:

1. run pellet via the command line in a similar fashion to line 228 of reasoning.py except two differences:
    Difference 1: replace 'realize' with 'extract'
    Difference 2: write the results to a new file representing the new ontology, something like '> InferredOntology.owl'
2. Then I just load the new ontology using owlready2.get_ontology('InferredOntology.owl')

I have SWRL rules in my original ontology and the InferredOntology contains the results of applying the SWRL rules. Perhaps it could solve the original problem posted on this thread?