How to extract the infobox data for a Wikipedia page using DBPedia? It would be great if any one can directly provide me with the query I can run at the DBPedia end-point to get the infobox contents as a key-value pair of property-value. For example,
Querying for Mahatma Gandhi should return something like:
Birth Date : 1869-10-02
Birth Name : Mohandas K. Gandhi,
Resting Place : Delhi,
Death Date : 1948-01-30
Since this is only a small part of the project I am working on, I am avoiding getting into the details of SPARQL, etc.
Assuming that your URI is dbpedia.org/resource/Mahatma_Gandhi (coming from en.wikipedia.org/wiki/Mahatma_Gandhi) you can simply do:
select * {
<http://dbpedia.org/resource/Mahatma_Gandhi> dbpedia-owl:birthDate ?birthDate;
dbpedia-owl:birthName ?name;
dbpedia-owl:restingPlace ?restingPlace;
dbpedia-owl:deathDate ?deathDate
}
try it on http://dbpedia.org/sparql (direct link)
if you will query for other resources I suggest you something like this
select * {
<http://dbpedia.org/resource/Mahatma_Gandhi> dbpedia-owl:birthName ?name.
OPTIONAL{<http://dbpedia.org/resource/Mahatma_Gandhi> dbpedia-owl:birthDate ?birthDate}
OPTIONAL{<http://dbpedia.org/resource/Mahatma_Gandhi> dbpedia-owl:restingPlace ?restingPlace}
OPTIONAL{<http://dbpedia.org/resource/Mahatma_Gandhi> dbpedia-owl:deathDate ?deathDate}
}