Note that there are some explanatory texts on larger screens.

plurals
  1. POfoaf and count in a sparql 1.1 query
    text
    copied!<p>I'm a beginner in SPARQL, so it would be great if you could help me. . I have a RDF doc like this:</p> <pre><code> @prefix foaf: &lt;http://xmlns.com/foaf/0.1/&gt; . @prefix lb: &lt;http://example.org/lastfm/&gt; . 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 . </code></pre> <p>and I want to find all users that can be reached from <code>lb:bob</code> by following the <code>foaf:knows</code> at most 3 times and who have listened to at least two tracks. I wrote a query like this:</p> <pre><code> PREFIX rdf: &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt; prefix foaf: &lt;http://xmlns.com/foaf/0.1/&gt; prefix lb: &lt;http://example.org/lastfm/&gt; select ?user where { 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(*)&gt;=2) } </code></pre> <p>but this error:</p> <pre><code>Encountered " "count" "count "" at line 12, column 23. Was expecting one of: "not" ... "in" ... &lt;INTEGER_POSITIVE&gt; ... &lt;DECIMAL_POSITIVE&gt; ... &lt;DOUBLE_POSITIVE&gt; ... &lt;INTEGER_NEGATIVE&gt; ... &lt;DECIMAL_NEGATIVE&gt; ... &lt;DOUBLE_NEGATIVE&gt; ... ")" ... "=" ... "!=" ... "&gt;" ... "&lt;" ... "&lt;=" ... "&gt;=" ... "||" ... "&amp;&amp;" ... "+" ... "-" ... "*" ... "/" ... </code></pre> <p>I know that my query has a lot of problems, would you please rewrite it for me?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload