0

I can fetch several metadata fields for a particular person using the following query at https://dbpedia.org/sparql:

prefix dbpedia: <http://dbpedia.org/resource/>
prefix dbpedia-owl: <http://dbpedia.org/ontology/>

select * {
  <http://dbpedia.org/resource/Mahatma_Gandhi> dbpedia-owl:birthName ?name.
  OPTIONAL{<http://dbpedia.org/resource/Mahatma_Gandhi> dbpedia-owl:birthDate ?birth_date}
  OPTIONAL{<http://dbpedia.org/resource/Mahatma_Gandhi> dbpedia-owl:deathDate ?death_date}
  OPTIONAL{<http://dbpedia.org/resource/Mahatma_Gandhi> dbpedia-owl:thumbnail ?thumbnail}
  OPTIONAL{<http://dbpedia.org/resource/Mahatma_Gandhi> dbpedia-owl:abstract  ?abstract FILTER (lang(?abstract) = 'en')}
}

I've also seen query syntax that shows how to get metadata fields on many people at once:

PREFIX  rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX  dbo: <http://dbpedia.org/ontology/>
PREFIX  dbp: <http://dbpedia.org/property/>

SELECT ?resource ?name
WHERE {
  ?resource  rdf:type  dbo:Person;
             dbp:name ?name.  
  FILTER (lang(?name) = 'en')
}
ORDER BY ASC(?name)
LIMIT 10000 OFFSET 10000

How can I combine these two so that I can fetch the birth_date, death_date, thumbnail, and abstract (in English) for all people in DBPedia? Any pointers others can offer would be hugely helpful!

duhaime
  • 25,611
  • 17
  • 169
  • 224
  • it's as simple as is. Your replace `` with the variable you used in the seconds query - and put all those triple patterns into your second query. – UninformedUser Oct 06 '21 at 06:12
  • Like `PREFIX dbo: PREFIX dbp: SELECT * WHERE { ?person a dbo:Person; dbp:name ?name FILTER (lang(?name) = 'en') OPTIONAL{ dbo:birthDate ?birth_date} OPTIONAL{ dbo:deathDate ?death_date} OPTIONAL{ dbo:thumbnail ?thumbnail} OPTIONAL{ dbo:abstract ?abstract FILTER (lang(?abstract) = 'en')} } limit 10` – UninformedUser Oct 06 '21 at 06:12
  • Thanks @UninformedUser but we're still hardcoding Gandhi into the query -- we want to get the birth_date, death_date, etc for each person (i.e. all the bios shouldn't be Gandhi's bio) – duhaime Oct 06 '21 at 10:56
  • 1
    My bad, I'm dumb and just copy pasted the wrong query, here we go: `PREFIX dbo: PREFIX dbp: SELECT * WHERE { ?person a dbo:Person; dbp:name ?name FILTER (lang(?name) = 'en') OPTIONAL{?person dbo:birthDate ?birth_date} OPTIONAL{?person dbo:deathDate ?death_date} OPTIONAL{?person dbo:thumbnail ?thumbnail} OPTIONAL{?person dbo:abstract ?abstract FILTER (lang(?abstract) = 'en')} } limit 10` – UninformedUser Oct 06 '21 at 14:12

0 Answers0