I'm trying to implement a rule that substract 1 years to a datetime and asign it to a data property using only SWRL
I've got an entity Product which got a data property creationDate equal to 2019-07-15T00:00:00.
My SWRL rule is the following :
Product(?p) ^ creationDate(?p, ?cd) ^ swrlb:yearMonthDuration(?dur, 1, 0)
^ swrlb:subtractYearMonthDurationFromDateTime(?result, ?cd, ?dur)
-> Product(?p) ^ yearBeforeCreation(?p, ?result)
I expect to get yearBeforeCreation equal to 2018-07-15T00:00:00
Right now I've tried the SWRL with Pellet and Drools
Thanks for your help !
I manage to make my SWRL work, look like it was something with protege. I've close/open, rewrite my rule and it work.
Related
I am writing a SWRL rule in OWL which can infer if a person is of driving age or not.
Person(?p), xsd:int[>= "18"^^xsd:int <= "65"^^xsd:int](?age), hasAge(?p, ?age) -> isDriverAge(?p, "True"xsd:Boolean)
It gives me Unexpected Character '[' error
I saw similar syntax for Object Property (found here: https://dior.ics.muni.cz/~makub/owl/ ) but that is also not working when I tweaked my ontology as per this code:
Person(?p), int[>= 18 , <= 65](?age), hasAge(?p, ?age) -> hasDriverAge(?p, True)
If you know the answer, could you please also provide me a resource which I can refer to write these rules. I don't want to keep coming back to stack and eat up other dev's time. Thanks
I have defined a class named "accelerate", set "Equivalent To" function as follow:
currentSpeed some xds:int [ < minSpeed ]
currentSpeed and minSpeed are DataProperties, and these value are assignmented by instance,
for example, create instance currentSpeed=25 minSpeed=30, compare them we know, currentSpeed is less than minSpeed, so I want protege can infer accelerate.
however it does not work, please help me.
Open protege swrltab
Add rule:
car(?c) ^ currentSpeed(?c, ?x) ^ minSpeed(?c, ?y) ^ swrlb: greaterThan(?y, ?x) -> accelerate(?c)
I'm a protégé newbie and did the pizza tutorial and read the 101 documentation. I'm trying to model a ontology like the following picture:
I have a person who has a style. The style can be a style_active or style_passive.
This style is determined by a index of two data properties:
ind_passive and ind_active, the bigger value should infer the style.
I had to create two individuals: style_active and style_passive, because they must be individuals to be assigned to the object property has_style.
How to infer the value of has_style object property based on ind_passive and ind_active data properties? Using a reasoner?
Is something wrong with this model?
I suceed in calculate the value of style object property based on two swrl rules. It does not work with a reasoner like HermiT (default in Protégé 5.5), but works in SWRLTab, that uses Drools.
The rules I used:
Name: Passive
Rule: Person(?p) ^ ind_passive(?p, ?ip) ^ ind_active(?p, ?ia) ^ swrlb:greaterThan(?ip, ?ia) -> has_style(?p, style_passive)
Name: Active
Rule: Person(?p) ^ ind_passive(?p, ?ip) ^ ind_active(?p, ?ia) ^ swrlb:greaterThan(?ia, ?ip) -> has_style(?p, style_active)
The reasoner Hermit could not be enabled after using this rules, because it does not supports "built-in atoms", like swrlb:greaterThan.
I'm trying to create an ontology of latin squares and make the reasoner solve it (starting with a simple 2x2 square and going from there) without much success.
The major problem I'm having is writing a rule in a way that sees what values are missing from the square.
I'm using dataProperty hasValue as an integer.
Something like:
Cell(?cell1) ^ hasValue(?cell1,?number1) ^
Cell(?cell2) ^ hasValue(?cell2,?number2) ^
Cell(?cell3) ^ hasValue(?cell3,?number3) ^
Cell(?cell4) ^ differentFrom(?number1, ?number2)
=>
hasValue(?Cell4,"desired result")
Thanks in advance.
I am using Protege 3.4 and I built my ontology and extended it with SWRL rules using SWRL and sqwrl built ins . The rules classifies instances of a class of the ontology ; the RHS is class assertion of an instance .It works successfully but when I change the values of the causes in the LHS no reclassification is done the instance is asserted to the same class
Why does this happen ? How to reclassify instances ?
ex:
SWRL rules:
1. Message(?m) hasInterest(?m,?i) hasCategory(?m,?c) sqwrl:makeset(?s1,?i) sqwrl:makeset(?s2,?c) sqwrl:intersection(?s3,?s1,?s2) sqwrl:size(?n,?s3) swrlb:greaterThan(?n,0) -> Ham(?m)
Message(?m) hasInterest(?m,?i) hasCategory(?m,?c) sqwrl:makeset(?s1,?i) sqwrl:makeset(?s2,?c) sqwrl:difference(?s3,?s1,?s2) sqwrl:size(?n,?s3) swrlb:greaterThan(?n,0) -> Spam(?m)
So once the message instance is classified as ham for example , whenever I change the values of i or c it will always be ham .