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
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.?
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)
Some background research on SPARQL is a very good idea. Just to point out the exact problem here, regex matches a string against a regular expression. So the following:
FILTER regex(str(?name), "Jeffrey D\\. Ullman") .
...will match "Jeffrey D. Ullman". The following:
FILTER regex(str(?name), "Ullman") .
...will match "Jeffrey D. Ullman" and anything with "Ullman" in ?name
. This filter:
FILTER regex(str(?name), "Ullman$") .
...will match any string ending with "Ullman". And this filter:
FILTER regex(str(?name), "^Jeffrey.*Ullman$") .
...will match any string starting with "Jeffrey", ending with "Ullman", with any character in between.
And so on...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.