Say I have this query...
SELECT ?human ?label WHERE { ?human wdt:P31 wd:Q15632617; rdfs:label ?label. FILTER(LANG(?label) = "en"). FILTER(STRSTARTS(?label, "Mr. ")). }
What if I wanted to see if any one of a humans name ends with "y" such as my last name does , their first, last, doesn't matter. I have a "d" and a "y" on the array returned from my name (if it were split by whitespace)
I did not see any special syntax or FILTER or Label service commands to help with splitting apart a Label by whitespace and then applying a filter on each string.
How would I accomplish this ?
Thad +ThadGuidry https://www.google.com/+ThadGuidry
this covers some of your query
SELECT ?human ((substr(?label,"0","4")) AS ?title) (substr(?label,"4") AS ?name) (strEnds( (substr(?name,"4")),"y") AS ?nameEndsWithY ) WHERE { ?human wdt:P31 wd:Q15632617; rdfs:label ?label. FILTER(LANG(?label) = "en"). FILTER(STRSTARTS(?label, "Mr. ")). }
On Mon, Sep 18, 2017 at 1:07 PM, Thad Guidry thadguidry@gmail.com wrote:
Say I have this query...
SELECT ?human ?label WHERE { ?human wdt:P31 wd:Q15632617; rdfs:label ?label. FILTER(LANG(?label) = "en"). FILTER(STRSTARTS(?label, "Mr. ")). }
What if I wanted to see if any one of a humans name ends with "y" such as my last name does , their first, last, doesn't matter. I have a "d" and a "y" on the array returned from my name (if it were split by whitespace)
I did not see any special syntax or FILTER or Label service commands to help with splitting apart a Label by whitespace and then applying a filter on each string.
How would I accomplish this ?
Thad +ThadGuidry
Wikidata mailing list Wikidata@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikidata
Hi
[snip]
I did not see any special syntax or FILTER or Label service commands to
help with splitting apart a Label by whitespace and then applying a filter on each string.
How would I accomplish this ?
Maybe with the function STRAFTER https://www.w3.org/TR/sparql11-query/#func-strafter
Example of use:
SELECT ?item ?itemLabel ?itemLabelafter WHERE { ?item wdt:P19 wd:Q647 ; rdfs:label ?itemLabel. FILTER (lang(?itemLabel) = "fr"). BIND ( STRAFTER(?itemLabel, " ") AS ?itemLabelafter ) } LIMIT 10
Cdlt, ~nicolas
Nicolas,
This is close to what I am needing and wanting. But how to get record rows for each word within a label ? It would be amazing if the Wikidata Label service already had the wiring to perform that and we could ask for "words" from each label.
Thoughts on how to do with without the enhancement request for the Label service ?
Thad +ThadGuidry https://www.google.com/+ThadGuidry
On Mon, Sep 18, 2017 at 12:49 PM, Nicolas VIGNERON < vigneron.nicolas@gmail.com> wrote:
Hi
[snip]
I did not see any special syntax or FILTER or Label service commands to
help with splitting apart a Label by whitespace and then applying a filter on each string.
How would I accomplish this ?
Maybe with the function STRAFTER https://www.w3.org/TR/ sparql11-query/#func-strafter
Example of use:
SELECT ?item ?itemLabel ?itemLabelafter WHERE { ?item wdt:P19 wd:Q647 ; rdfs:label ?itemLabel. FILTER (lang(?itemLabel) = "fr"). BIND ( STRAFTER(?itemLabel, " ") AS ?itemLabelafter ) } LIMIT 10
Cdlt, ~nicolas
Wikidata mailing list Wikidata@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikidata
I don’t think there’s any SPARQL function that can transform a single result into multiple results (one for each string fragment, in that case). But for your request, a regex works:
SELECT ?human ?label WHERE { ?human wdt:P31 wd:Q15632617; rdfs:label ?label. FILTER(LANG(?label) = "en") FILTER(REGEX(?label, "y\s")) }
On 18.09.2017 19:07, Thad Guidry wrote:
Say I have this query...
SELECT ?human ?label WHERE { ?human wdt:P31 wd:Q15632617; rdfs:label ?label. FILTER(LANG(?label) = "en"). FILTER(STRSTARTS(?label, "Mr. ")). }
What if I wanted to see if any one of a humans name ends with "y" such as my last name does , their first, last, doesn't matter. I have a "d" and a "y" on the array returned from my name (if it were split by whitespace)
I did not see any special syntax or FILTER or Label service commands to help with splitting apart a Label by whitespace and then applying a filter on each string.
How would I accomplish this ?
Thad +ThadGuidry https://www.google.com/+ThadGuidry
Wikidata mailing list Wikidata@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikidata