Little Problem with SparQL rules

4 views
Skip to first unread message

Agustin pretto

unread,
Sep 8, 2014, 12:02:31 AM9/8/14
to sta...@clarkparsia.com
Hi Guys How are you?? 

I have a little problem ( could be a syntax problem) when I try to execute a Query based in a SparQl rule...

More exactly, I defined my ontology like this:

Class:
  • Point
DataTypeProperties: ( Domain -> Range)
  • X ( Point -> Double)
  • Y ( Point -> Double)
Object Properties: ( Domain -> Range)
  • equalTo (Point -> Point)

ok... and says that I have 2 individuals ( P1 and P2) with same X and Y

if I try a query like below, to find which Points have same coordinates:

PREFIX : //load the prefix
SELECT ?p1 ?p2
WHERE{

   ?p1 a :Point.
   ?p2 a :Point.
   ?p1 :X ?x1.
   ?p2 :X ?x2.
   ?p1 :Y ?y1.
   ?p2 :Y ?y2.
   FILTER ( (?x1 = ?x2) && (?y1 = ?y2) && ( ?p1 != ?p2) )
}

it Works FINE!!! and lists P1 and P2.... But if I put the where statement in a rule to define the "equalTo" objectProperty like this:

 
@prefix rule: <tag:stardog:api:rule:> .

[] a rule:SPARQLRule ;
rule:content """
PREFIX : //Ontology Prefix goes here
IF {
   ?p1 a :Point.
   ?p2 a :Point.
   ?p1 :X ?x1.
   ?p2 :X ?x2.
   ?p1 :Y ?y1.
   ?p2 :Y ?y2.
   FILTER ( (?x1 = ?x2) && (?y1 = ?y2) && ( ?p1 != ?p2) )
}
THEN 
{
  ?p1 :equalTo ?p2.
} """.


Now If I try the same query with the "equalTo" ObjectProperty should return the same result... 

PREFIX : //load the prefix
SELECT ?p1 ?p2
WHERE{

   ?p1 :equalTo ?p2.

}

but always retun 0 rows...

I don't understand what I'm doing wrong in this... or there's some limitations in stardog with the rule definitions? 


Thanks

Agustin

Héctor Pérez-Urbina

unread,
Sep 11, 2014, 11:43:45 AM9/11/14
to stardog, tiag...@gmail.com
Hi,

I created a test case with your rule and a minimal set of data (a X x1, b X x1, a Y x2, b Y x2) and it is producing the expected results. Are you using the reasoning level SL? Are you storing the rule in a particular named graph?

--
-- --
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



--
Best,
Héctor

Agustin pretto

unread,
Sep 11, 2014, 1:43:52 PM9/11/14
to sta...@clarkparsia.com, tiag...@gmail.com
Hi Héctor, how're you?

I'm using the SL reasoning Level for the query, but still have the same results ( TT___TT).
I Upload the Ontology and the rule that I defined... Can you take a look??

Notes:

this is the query that gives the correct results... (2 rows)

select *
where {

?p1 a :Point.
    ?p2 a :Point.
    ?p1 :X ?x1.
    ?p1 :Y ?y1.

    ?p2 :X ?x2.
    ?p2 :Y ?y2.
       
        FILTER ((?x1 = ?x2) && (?y1 = ?y2)&& (?p1 != ?p2)).
}


and this is the query that I try to do... ( shoul return the same results) ( 0 rows)


select *
where {

?p1 a :Point.
    ?p2 a :Point.
    ?p1 :equalTo ?p2.
}

Thanks

Agustin
PointOntology.ttl
PointRule.ttl

Héctor Pérez-Urbina

unread,
Sep 11, 2014, 3:45:35 PM9/11/14
to stardog
Thanks for the files. It turned out your rule is not syntactically valid. Simply remove the '.' after '<http://www.semanticweb.org/pc/ontologies/PointOntology.owl#>'.

Agustin pretto

unread,
Sep 18, 2014, 2:00:36 PM9/18/14
to sta...@clarkparsia.com
Great! It Works...

Now (again) I have some trouble in the rule definition... I need to add a filter with not exists statement, but it doesn't return anything.

The Exists its available to use in the rule definition?

Greeting

Agustin

Mike Grove

unread,
Sep 18, 2014, 2:30:14 PM9/18/14
to stardog
Stardog rules have the same expressivity as SWRL rules so you can only have BGPs or FILTER expressions in your rule body.

Cheers,

Mike
 

Greeting
Reply all
Reply to author
Forward
0 new messages