Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pulling details from Wikidata #30

Open
jsanz opened this issue Nov 6, 2020 · 0 comments · May be fixed by #31
Open

Pulling details from Wikidata #30

jsanz opened this issue Nov 6, 2020 · 0 comments · May be fixed by #31

Comments

@jsanz
Copy link
Collaborator

jsanz commented Nov 6, 2020

I wanted to explore to enrich the map popups with details from wikidata to offer more details of the woman right in the map.

I've crafted a SPARQL query that takes as a single parameter the name of the woman as in the Wikipedia title and returns some details: Name and gender, description in Spanish, birth and death dates, occupations*, and picture.

* it's a pity that in Spanish they come back in male variation, I need to investigate if wikidata offers them somehow in female version as in actriz instead of actor.

This query could be run when the user clicks on a street to fetch all these details using the Wikidata SPARQL endpoint and JSON format and render them appropriately.

Would this be something worth trying? Happy to discuss approaches and possibilities.

cc @jessisena @seleneyang

SPARQL query
SELECT 
  ?id 
  (?idLabel AS ?name) 
  (?desc as ?description) 
  (?genderLabel AS ?gender)
  (SAMPLE(?births) AS ?birth) 
  (SAMPLE(?deaths) AS ?death) 
  (SAMPLE(?pic) AS ?picture) 
  (GROUP_CONCAT(DISTINCT ?occupationsLabel; SEPARATOR = ", ") AS ?occupations) 
WHERE {
  VALUES ?wikiTitle {
    "Ada Lovelace"@es
  }
  ?wiki schema:about ?id;
    schema:isPartOf <https://es.wikipedia.org/>;
    schema:name ?wikiTitle.
  
  OPTIONAL { ?id wdt:P21 ?gender. }
  OPTIONAL { ?id wdt:P569 ?births. }
  OPTIONAL { ?id wdt:P570 ?deaths. }
  OPTIONAL { ?id wdt:P106 ?occupations. }
  OPTIONAL { ?id wdt:P18 ?pic }.
  OPTIONAL { ?id schema:description ?desc }.
  FILTER (LANG(?desc) = "es") 
  
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "es".
    ?id rdfs:label ?idLabel.
    ?gender rdfs:label ?genderLabel.
    ?occupations rdfs:label ?occupationsLabel.
  }
}
GROUP BY ?id ?idLabel ?desc ?genderLabel ?wiki
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant