A simple SWRL rule with swrlb:

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

A simple SWRL rule with swrlb:

FrankW
Hi,

I am adding a simple rule to my SWRLTab but when I activate the reasoner it
does not get updated in the ontology.
I use installed the newest Pellet Reasoner (Hermit does not work) and use
protege 5.2

I get this from the SWRL introduction and just replicated it:
Rule:S1

autogen0:Rectangle(?r) ^ autogen0:hasWidthInMeters(?r, ?w) ^
autogen0:hasHeightInMeters(?r, ?h) ^ swrlb:multiply(?areaInSquareMeters, ?w,
?h) -> autogen0:hasAreaInSquareMeters(?r, ?areaInSquareMeters)

I added the class Rectangle, an Instance rectangle1, and the data properties
for it, except the hasAreaInSquaremeters, that I added only as a datatype
property in protege. the status is ok.

But when I run the reasoner there is not hasAreaInSquaremeters datatype with
the corresponding value inferred.

I tried other rules without the swrlb: prefix and they seem to work.

What might be the issue here?

Thank you.





--
Sent from: http://protege-project.136.n4.nabble.com/Protege-User-f4659818.html
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: A simple SWRL rule with swrlb:

Michael DeBellis-2
Frank, Have you tried using the SQWRLTab to debug the rule? For example you could write the SQWRL rule: 

Rectangle(?r) ^ hasWidthInMeters(?r, ?w) ^
hasHeightInMeters(?r, ?h) ^ swrlb:multiply(?areaInSquareMeters, ?w,
?h) -> sqwrl:select(?r, ?areaInSquareMeters)

to see if the rule is firing at all. One thing I do sometimes is to decompose a rule and then use SQWRL step by step to see where it's not doing what I expect it to. So for example if you run the rule above and the SQWRLTab says the rule never fired you could try:

Rectangle(?r) ^ hasWidthInMeters(?r, ?w) ^
hasHeightInMeters(?r, ?h)  -> sqwrl:select(?r, ?w,?h)

That would tell you if you are getting the values you expect for the instance(s) of Rectangle in your ontology. Another thing to be aware of is the datatype for your data properties. In the past that has caused issues for me with the math builtins. Although, when that happens there is usually a fairly intuitive error message such as "tried to coerce datatype xsd:Literal to xsd:Integer"

Also, if you want to send your ontology I could take a quick look at it and see if I can spot the problem. The rule seems to me as if it should work. 

Michael


On Fri, May 25, 2018 at 7:04 AM, FrankW <[hidden email]> wrote:
Hi,

I am adding a simple rule to my SWRLTab but when I activate the reasoner it
does not get updated in the ontology.
I use installed the newest Pellet Reasoner (Hermit does not work) and use
protege 5.2

I get this from the SWRL introduction and just replicated it:
Rule:S1

autogen0:Rectangle(?r) ^ autogen0:hasWidthInMeters(?r, ?w) ^
autogen0:hasHeightInMeters(?r, ?h) ^ swrlb:multiply(?areaInSquareMeters, ?w,
?h) -> autogen0:hasAreaInSquareMeters(?r, ?areaInSquareMeters)

I added the class Rectangle, an Instance rectangle1, and the data properties
for it, except the hasAreaInSquaremeters, that I added only as a datatype
property in protege. the status is ok.

But when I run the reasoner there is not hasAreaInSquaremeters datatype with
the corresponding value inferred.

I tried other rules without the swrlb: prefix and they seem to work.

What might be the issue here?

Thank you.





--
Sent from: http://protege-project.136.n4.nabble.com/Protege-User-f4659818.html
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user


_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: A simple SWRL rule with swrlb:

samsontu
The rule should work. There is something else going on if Pellet doesn’t give you the inference. Attached is an ontology where Pellet infers the area of a rectangle.

With best regards,
Samson


On May 25, 2018, at 7:58 AM, Michael DeBellis <[hidden email]> wrote:

Frank, Have you tried using the SQWRLTab to debug the rule? For example you could write the SQWRL rule: 

Rectangle(?r) ^ hasWidthInMeters(?r, ?w) ^
hasHeightInMeters(?r, ?h) ^ swrlb:multiply(?areaInSquareMeters, ?w,
?h) -> sqwrl:select(?r, ?areaInSquareMeters)

to see if the rule is firing at all. One thing I do sometimes is to decompose a rule and then use SQWRL step by step to see where it's not doing what I expect it to. So for example if you run the rule above and the SQWRLTab says the rule never fired you could try:

Rectangle(?r) ^ hasWidthInMeters(?r, ?w) ^
hasHeightInMeters(?r, ?h)  -> sqwrl:select(?r, ?w,?h)

That would tell you if you are getting the values you expect for the instance(s) of Rectangle in your ontology. Another thing to be aware of is the datatype for your data properties. In the past that has caused issues for me with the math builtins. Although, when that happens there is usually a fairly intuitive error message such as "tried to coerce datatype xsd:Literal to xsd:Integer"

Also, if you want to send your ontology I could take a quick look at it and see if I can spot the problem. The rule seems to me as if it should work. 

Michael


On Fri, May 25, 2018 at 7:04 AM, FrankW <[hidden email]> wrote:
Hi,

I am adding a simple rule to my SWRLTab but when I activate the reasoner it
does not get updated in the ontology.
I use installed the newest Pellet Reasoner (Hermit does not work) and use
protege 5.2

I get this from the SWRL introduction and just replicated it:
Rule:S1

autogen0:Rectangle(?r) ^ autogen0:hasWidthInMeters(?r, ?w) ^
autogen0:hasHeightInMeters(?r, ?h) ^ swrlb:multiply(?areaInSquareMeters, ?w,
?h) -> autogen0:hasAreaInSquareMeters(?r, ?areaInSquareMeters)

I added the class Rectangle, an Instance rectangle1, and the data properties
for it, except the hasAreaInSquaremeters, that I added only as a datatype
property in protege. the status is ok.

But when I run the reasoner there is not hasAreaInSquaremeters datatype with
the corresponding value inferred.

I tried other rules without the swrlb: prefix and they seem to work.

What might be the issue here?

Thank you.





--
Sent from: http://protege-project.136.n4.nabble.com/Protege-User-f4659818.html
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user

_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user


_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user

swrltest.owl (11K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: A simple SWRL rule with swrlb:

FrankW
Thank you Michael DeBellis and samsontu for your input,

Michael DeBellis:
I tried the query and it returns the correct result of the area size. So the
rule seems to fire. Still the reasoner does not seem to infer this
information.

samsontu:
I checked your ontology and it seems like the one I did, except to some
naming differences. When I execute the query I also get that your rule fires
and get a result for the area. But still the reasoner does not yield an
inference.

Anything else I can try?
Is there something I am not seeing?

Thank you.

BTW the problem does not seem to be the swirl rule but rather that it the
inference of the datatype property.
The datatype is xsd:integer but also tried it with double




--
Sent from: http://protege-project.136.n4.nabble.com/Protege-User-f4659818.html
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: A simple SWRL rule with swrlb:

FrankW
I solved the issue: The default properties of the reasoner is not to display
inferred data properties and a box has first to be activated for displaying
data properties. Now it works.



--
Sent from: http://protege-project.136.n4.nabble.com/Protege-User-f4659818.html
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user