Osher Hajaj
Osher Hajaj

Reputation: 61

Querying Dbpedia resource given its wikiPageID doesn't work for some ID's

I'm trying to query data about a specific person from dbpedia given his wikiPageID. I've tried this SPARQL query to query about Michael Jackson:

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

SELECT ?name (SAMPLE (?photoLink) as ?photo) (SAMPLE (?occupation) as occup)
(SAMPLE (?spouse) as ?spouses) (SAMPLE (?spName) as ?sname)
(SAMPLE (?spOccupation) as ?spOccu) (SAMPLE (?deathPlace) as ?death)
(SAMPLE(?birthPlace) as ?birth) (SAMPLE(?deathDate) as ?dDate) 
(SAMPLE( ?birthDate) as ?bDate)  {

VALUES ?wikiPageID { 14995351 }
?res a dbo:Person. 
?res dbp:name ?name.
?res dbo:wikiPageID ?wikiPageID.
?res dbp:birthPlace ?birthPlace. 
?res dbp:birthDate ?birthDate. OPTIONAL{?res dbo:occupation ?occupation}.
OPTIONAL{?res dbo:thumbnail ?photoLink}.
OPTIONAL{?res dbo:spouse ?spouse. ?spouse dbp:name ?spName.
?spouse dbo:occupation ?spOccupation}.  
OPTIONAL{?res dbp:deathDate ?deathDate. ?res dbp:deathPlace ?deathPlace}. 
}

GROUP BY (?name)

The query returns empty results. However, when i change to someone else's wikiPageID (e.g Toby Maguire - 163228) it works. What could be the cause for the difference?

Upvotes: 0

Views: 384

Answers (1)

Median Hilal
Median Hilal

Reputation: 1531

If you check Michael Jackson page on DBpedia http://dbpedia.org/page/Michael_Jackson, you can easily find that it doesn't have a dbp:name property, or a dbp:birthPlace, not even a dbp:birthDate. To resolve that, add OPTIONAL to these properties as well:

OPTIONAL{?res dbp:name ?name}.
OPTIONAL{?res dbp:birthPlace ?birthPlace}.
OPTIONAL{dbp:birthDate ?birthDate}.

Upvotes: 2

Related Questions