I'm not aware of any tutorial, but afaik you can't do what you did here
with SPARQL in Jena rules without writing custom built-ins or by
extending the existing ones because:

* the "difference" built-in does only work for numbers right now [1]

* there is no support for duration type at all it looks like


So, so far you could only compare datetime values via lessThan, le,
greaterThan, ge but there is no other built-in with support for date
values so far. Others might indeed correct me if I'm wrong of.


It looks like, you have to extend the rule system by custom built-ins -
it's not that difficult though [2]

[1]
https://github.com/apache/jena/blob/master/jena-core/src/main/java/org/apache/jena/reasoner/rulesys/builtins/Difference.java#L68
[2] https://jena.apache.org/documentation/inference/#builtins

> Could people recommend a good reference/tutorial on how to use built-ins 
> (greaterThan, difference, now etc) with dates (e.g., datetime, duration and 
> so on) in rules for the GenericRuleReasoner?
>
> Example: 
>
> Assume a KB of conferences with their deadlines as xsd:dateTime. 
>
> Here are examples of SPARQL queries to find conferences whose deadlines are 
> passed:
>
> SELECT * WHERE { 
>       ?subject here:hasDeadline ?date . 
>       BIND((xsd:dateTime(?date) - now()) AS ?Span)
>       FILTER(?Span < "P0D"^^xsd:duration)
>       } 
>
> SELECT * WHERE { 
>       ?subject here:hasDeadline ?date . 
>       FILTER(now() > xsd:dateTime(?date)) 
>       }
>
> Suppose instead I wanted to infer some attribute of the conference, e.g: 
>
> ?subject here:hasStatus here:DeadlinePassed 
>
> I don't really get how to do that in a rule and I can't quite figure if I'm 
> misusing the built-ins or just mixing SPARQL and rule syntax (e.g., when 
> trying to coerce variables to datatypes). 
>
> There's a bunch of recurring questions around that sort of rules but I can't 
> quite find any answer that's giving clear examples. 
>
> Thus I would find it useful if anybody could point at a resource that goes 
> through some sort of how to do date comparison and use that in rules as the 
> Jena doc on built-in is not self-contained in that respect.
>
> https://jena.apache.org/documentation/inference/#rules
>
>
> With many thanks and kind regards, 
> Pierre
>
> THIS E-MAIL MAY CONTAIN CONFIDENTIAL AND/OR PRIVILEGED INFORMATION. 
> IF YOU ARE NOT THE INTENDED RECIPIENT (OR HAVE RECEIVED THIS E-MAIL 
> IN ERROR) PLEASE NOTIFY THE SENDER IMMEDIATELY AND DESTROY THIS 
> E-MAIL. ANY UNAUTHORISED COPYING, DISCLOSURE OR DISTRIBUTION OF THE 
> MATERIAL IN THIS E-MAIL IS STRICTLY FORBIDDEN. 
>
> IN ACCORDANCE WITH MIFID II RULES ON INDUCEMENTS, THE FIRM'S EMPLOYEES 
> MAY ATTEND CORPORATE ACCESS EVENTS (DEFINED IN THE FCA HANDBOOK AS 
> "THE SERVICE OF ARRANGING OR BRINGING ABOUT CONTACT BETWEEN AN INVESTMENT 
> MANAGER AND AN ISSUER OR POTENTIAL ISSUER"). DURING SUCH MEETINGS, THE 
> FIRM'S EMPLOYEES MAY ON NO ACCOUNT BE IN RECEIPT OF INSIDE INFORMATION 
> (AS DESCRIBED IN ARTICLE 7 OF THE MARKET ABUSE REGULATION (EU) NO 596/2014). 
> (https://www.handbook.fca.org.uk/handbook/glossary/G3532m.html)
> COMPANIES WHO DISCLOSE INSIDE INFORMATION ARE IN BREACH OF REGULATION 
> AND MUST IMMEDIATELY AND CLEARLY NOTIFY ALL ATTENDEES. FOR INFORMATION 
> ON THE FIRM'S POLICY IN RELATION TO ITS PARTICIPATION IN MARKET SOUNDINGS, 
> PLEASE SEE https://www.horizon-asset.co.uk/market-soundings/. 
>
> HORIZON ASSET LLP IS AUTHORISED AND REGULATED 
> BY THE FINANCIAL CONDUCT AUTHORITY.
>
>
>
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center

Reply via email to