Skip to content

Pulling details from Wikidata #30

Description

@jsanz

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions