i'm beginner in sparql, great if me. . have rdf doc this:
@prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix lb: <http://example.org/lastfm/> . lb:bob foaf:knows lb:user2, lb:user3, lb:user4 ; foaf:age 25 ; lb:listenedto lb:track1, lb:track2 ; lb:topartist lb:artist1, lb:artist2 . lb:user2 foaf:knows lb:user5, lb:user6 ; foaf:age 40 ; lb:listenedto lb:track1, lb:track2, lb:track3 ; lb:topartist lb:artist2, lb:artist4 . lb:user3 foaf:knows lb:user5, lb:bob, lb:user6 ; foaf:age 19 ; lb:listenedto lb:track2, lb:track3, lb:track4 ; lb:topartist lb:artist2, lb:artist3 . lb:user4 lb:listenedto lb:track2, lb:track3, lb:track4 ; foaf:age 61 ; lb:topartist lb:artist3, lb:artist4, lb:artist5 . lb:user5 foaf:knows lb:user7 ; foaf:age 23 ; lb:topartist lb:artist1, lb:artist3 .
and want find users can reached lb:bob
following foaf:knows
@ 3 times , have listened @ least 2 tracks. wrote query this:
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> prefix foaf: <http://xmlns.com/foaf/0.1/> prefix lb: <http://example.org/lastfm/> select ?user { lb:bob foaf:knows | foaf:knows/foaf:knows| foaf:knows/foaf:knows/foaf:knows ?user. ?user lb:listenedto ?tracks minus{lb:bob lb:listenedto ?track} filter (?tracks count(*)>=2) }
but error:
encountered " "count" "count "" @ line 12, column 23. expecting 1 of: "not" ... "in" ... <integer_positive> ... <decimal_positive> ... <double_positive> ... <integer_negative> ... <decimal_negative> ... <double_negative> ... ")" ... "=" ... "!=" ... ">" ... "<" ... "<=" ... ">=" ... "||" ... "&&" ... "+" ... "-" ... "*" ... "/" ...
i know query has lot of problems, please rewrite me?
how about:
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> prefix foaf: <http://xmlns.com/foaf/0.1/> prefix lb: <http://example.org/lastfm/> select ?user { lb:bob foaf:knows | foaf:knows/foaf:knows| foaf:knows/foaf:knows/foaf:knows ?user. ?user lb:listenedto ?tracks } group ?user having (count(?tracks) > 2)
you have minus
in original query i'm not sure about. trying remove lb:bob
binding ?user
, perhaps? filter (?user != lb:bob)
stop that.
Comments
Post a Comment