Selecting maximum value with SPARQLRule

2 views
Skip to first unread message

Emmelie Verborgh

unread,
Aug 11, 2014, 9:14:43 AM8/11/14
to sta...@clarkparsia.com
Hi,

Through an ICV rule, I would like to select the entry with the most recent date (given by the variable pao2time). Right now, I'm having following rule, but it doesn't seem to work.

[] a rule:SPARQLRule ;
        rule:content """
        < ... prefix declarations ... >
        IF {
                ?adm a general:PatientAdmission . 
                ?adm pao2fio2:hasPao2fio2 ?pao2 . 
                ?pao2 a pao2fio2:Pao2fio2 . 
                ?pao2 temp:hasTime ?pao2time . 
                BIND(fn:max(?pao2time) AS ?pao2timemax)
                FILTER(?pao2time = ?pao2timemax)
        }
        THEN {
                do something
        }
""" .

Is there another way? I've already tried using ORDER BY, LIMIT and subqueries. It looks like they are not supported in the SPARQLRules.

Thanks,
Emmelie

Evren Sirin

unread,
Aug 11, 2014, 10:30:13 AM8/11/14
to Stardog
You cannot accomplish what you are trying to do with inference rules.
Similar to negation aggregate functions like max would make a rule
non-monotonic and are not supported. With non-monotonic rules, even
adding a new triple can invalidate a previous inference and the
semantics get complicated.

You mention ICV which is only for validating contents and not making
new inferences. In ICV, you can use negation, aggregation and all the
other SPARQL functions in your validation queries.

Best,
Evren
> --
> -- --
> You received this message because you are subscribed to the C&P "Stardog"
> group.
> To post to this group, send email to sta...@clarkparsia.com
> To unsubscribe from this group, send email to
> stardog+u...@clarkparsia.com
> For more options, visit this group at
> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
Reply all
Reply to author
Forward
0 new messages