I am a newbie to Stardog DB and try to use the Rule and the reasoning feature of Stardog. I expect from enabling the reasoning and using the following simple rule to update values of individuals matching to the IF condition. It does happening. I will truly appreciate if you can help me.
Here is the simple rule that tries to update the state of a ?x based on the state of another object ?p.
I added the rule to the database and the web interface for database browsing shows it as a SPARQLRule. I also enabled reasoning and chose the SL reasoning algorithm.
IF { ?x a :Path.
?x :hasActive ?p.
?p :hasState ?s.
BIND ( ?s AS ?state).
}
THEN {
?x :hasState ?state .
}
Hi Jess,
Thanks for your reply,
I am not running any query, I am under the impression of this rule will fire whenever any changes in the db are happening and I expect it updates the ?X state with the state of ?P. To test if it works, I simply change the state of the ?P to “Inactive” and expect ?X :hasState "active" changes to ?X :hasState "Inactive" automaticlly.
It sounds like you are expecting the rules to materialize triples and act as sort of a "trigger." Stardog does not perform materialization; we perform Query Rewriting at query runtime.
In short, If you run the query select * where {?x :hasState "active"}, it will give you all of the entities that either explicitly have that triple in the db, or for which the rule applies. Instead of looking for ?X :hasState "Inactive" in the database, try running the query above, changing a state, and running it again. You should see the results you're looking for.
Hi,
Thanks for your reply, I can see the expected results by running the query (1): select * where {?x :hasState “Inactive”}, however, if I run the select * where {?x :hasState “active”} query it also returns the triples supposed to be “Inactive” ! I guess this time it is because of it has explicit value of “active” . It is a preplex behaviour to me, is there anyway that I can get more consistent outputs?
Thanks !
Thanks for your reply,
You can find a simplified data set from test-arsham-w-const-2-1.ttl (2.3 KB)
For this data set, if I run the query: SELECT * WHERE {?p a of:Path; of:hasState 'Inactive'} returns Nil if the reasoning is OFF and return the three paths if the reasoning is ON as it should be. However, If I run SELECT * WHERE {?p a of:Path; of:hasState 'active'} it always (with/without reasoning) return the same three defined paths.
If I change the rule to the one mentioned in the previous post, it did not work at all. I have to specify the value for the Dataproperty :hasState to make it work as described.