Write a SPARQL query to fetch (up to) 50 Wikidata items representing people who identify…
- User
Write a SPARQL query to fetch (up to) 50 Wikidata items representing people who identify as non-binary
- Assistant
Sure, here is a SPARQL query to fetch (up to) 50 Wikidata items representing people who identify as non-binary:
codePREFIX wd: <http://www.wikidata.org/wiki/> PREFIX wdt: <http://www.wikidata.org/wiki/Property:> SELECT ?item ?name ?gender WHERE { ?item wdt:P31 wd:Q5. ?item wdt:P106 ?gender. FILTER(lang(?gender) = "en" && regex(?gender, "non-binary")). ?item rdfs:label ?name. FILTER(lang(?name) = "en"). LIMIT 50 }This query will return the following information for each Wikidata item:
- The item's URI (
?item) - The item's name (
?name) - The item's gender (
?gender)
The query will only return items that have a gender label in English that contains the string "non-binary". The query will also limit the results to 50 items.
Here is an example of the output of this query:
code - The item's URI (
- User
Filter younger than 50
- Assistant
Certainly! Here's an updated version of the SPARQL query that includes a filter to fetch up to 50 Wikidata items representing people who identify as non-binary and are younger than 50 years old:
codeSELECT DISTINCT ?person ?personLabel ?genderLabel ?birthDate WHERE { ?person wdt:P31 wd:Q5; # Instance of human wdt:P21 wd:Q48270; # Has gender identity as non-binary wdt:P569 ?birthDate; # Has birth date rdfs:label ?personLabel. FILTER(LANG(?personLabel) = "en"). OPTIONAL { ?person wdt:P21 ?gender. ?gender rdfs:label ?genderLabel. FILTER(LANG(?genderLabel) = "en"). } FILTER(YEAR(NOW()) - YEAR(?birthDate) < 50) } LIMIT 50In this updated query, the
wdt:P569 ?birthDatestatement retrieves the birth date of each person. TheFILTER(YEAR(NOW()) - YEAR(?birthDate) < 50)statement filters the results to include only those individuals who are younger than 50 years old.Feel free to adjust the age limit according to your requirements by modifying the value in the condition.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)