Search code examples
sparqlrdf

SPARQL query DBLP


I am running this query

SELECT *
WHERE
{
?s dc:creator ?name .
?s rdf:type swrc:Article .
FILTER regex(str(?name), "Jeffrey", "D.", "Ullman") .
}

and I am getting an error of:

Encountered " "," ", "" at line 16, column 41.
Was expecting one of:
    <LANGTAG> ...
    <INTEGER_POSITIVE> ...
    <DECIMAL_POSITIVE> ...

What is the matter with that, am I not conforming with the guidelines? I've searched a bit around and I found the same syntax in various posts.

EDIT:

when I am asking for

SELECT * WHERE { ?s rdf:type swrc:Article . ?s dc:creator ?name . }

I get back: s name <http://dblp.l3s.de/d2r/resource/publications/conf/www/BeszteriV07> [http] <http://dblp.l3s.de/d2r/resource/authors/Istvan_Beszteri> [http] in a single line where the fist URI is the ?s and the second the ?name.

Now I know for a fact that there is an author named "Jeffrey D. Ullman" and I query for:

SELECT * WHERE { ?s rdf:type swrc:Article . ?s dc:creator ?name . FILTER regex(str(?name), "Jeffrey") } LIMIT 10.

I then get back for example: s name <http://dblp.l3s.de/d2r/resource/publications/conf/www/LimWPVA07> [http] <http://dblp.l3s.de/d2r/resource/authors/Jeffrey_Scott_Vitter> [http]

So the question here is how will I be able to match "Jeffrey D. Ullman" and see all the Articles he has written.?


Solution

  • Your regex function syntax is incorrect see SPARQL1.1 spec. Note that regex takes exactly two or three arguments, the first being the text, the second the pattern, and the final an optional string containing flags.

    17.4.3.14 REGEX

    xsd:boolean  REGEX (string literal text, simple literal pattern) 
    xsd:boolean  REGEX (string literal text, simple literal pattern, simple literal flags)