Hi to all!
I'm very new to Wikidata sparql, and I've only finished the tutorial.
My question is about filtering people on their given name.
I've tried:
SELECT DISTINCT ?person ?personLabel WHERE { ?person wdt:P31 wd:Q5. ?person wdt:P735 ?givenName. SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } FILTER(STRSTARTS(?givenName, "A")) } LIMIT 1000
But there are no results (I'm filtering on the person with a given name starting with an "A"). What am I doing wrong? Thanks a lot in advance! Cheers
Hi
On Mon, Apr 2, 2018 at 4:22 PM, gilga gilga gilga@hotmail.fr wrote:
SELECT DISTINCT ?person ?personLabel WHERE { ?person wdt:P31 wd:Q5. ?person wdt:P735 ?givenName. SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } FILTER(STRSTARTS(?givenName, "A")) } LIMIT 1000
so that's trying to filter the given name item not the label of the given name item.
there's a few examples at https://www.wikidata.org/wiki/Wikidata:SPARQL_tutorial#FILTER that try to do FILTER(STRSTARTS(?humanLabel, "Mr. ")). the first one is broken but I assume it used to work.
adapt the second "Mr. " example there and I get: SELECT DISTINCT ?person ?personLabel ?givenNameLabel ?gnlabel WHERE { ?person wdt:P31 wd:Q5. ?person wdt:P735 ?givenName. ?givenName rdfs:label ?gnlabel. FILTER(LANG(?gnlabel) = "[AUTO_LANGUAGE]"). FILTER(STRSTARTS(?gnlabel, "A")) SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }
that times out even with LIMIT 5. but if I test with a smaller dataset (fictional humans) it appears to be written properly:
SELECT DISTINCT ?person ?personLabel ?givenNameLabel ?gnlabel WHERE { ?person wdt:P31 wd:Q15632617. ?person wdt:P735 ?givenName. ?givenName rdfs:label ?gnlabel. FILTER(LANG(?gnlabel) = "[AUTO_LANGUAGE]"). FILTER(STRSTARTS(?gnlabel, "A")) SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }
-Jeremy