Let's start from the begin. There are some persons stored in graph database with predicates like birthDate, name, etc. I'm currently trying to write custom rule which add some new fact for persons older than e.g. 50 years. So to achieve that two steps are needed: calculate age and filter age.
SPARQL query could look like below:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX drl: <http://...>
SELECT DISTINCT ?person ?age
WHERE {
?person rdf:type drl:Person.
?person drl:Person.birthDate/drl:value ?birthDate;
BIND(year(now()) - year(?birthDate) as ?age)
FILTER (?age > 50)
}
But how to write such rule? According to https://graphdb.ontotext.com/documentation/standard/reasoning.html#entailment-rules
The syntax of a rule definition is as follows:
Id: <rule_name> <premises> <optional_constraints> ------------------------------- <consequences> <optional_constraints>
So is it possible to use BIND and FILTER keywords inside <premises>
or <optional_constraints>
?
As I suppose the answear is: NOT :(
Maybe there is anoter way to have such rule?
Seems that SPARQL SPIN functions and magic predicates are not an option for GraphDB?