SPARQL查询使用DBPedia提取Wikipedia信息框数据

时间:2014-07-06 22:35:45

标签: sparql wikipedia dbpedia

如何使用 DBPedia 提取维基百科页面的信息框数据?如果任何人能直接向我提供我可以在DBPedia端点运行的查询以获取信息框内容作为 property-value 。例如,

查询圣雄甘地应该返回类似的内容:

出生日期:1869-10-02
出生名称:Mohandas K. Gandhi,
休息地:德里,
死亡日期:1948-01-30

由于这只是我正在研究的项目的一小部分,我无法深入了解SPARQL的细节等。

2 个答案:

答案 0 :(得分:2)

假设您的URI是dbpedia.org/resource/Mahatma_Gandhi(来自en.wikipedia.org/wiki/Mahatma_Gandhi),您可以这样做:

select * {
<http://dbpedia.org/resource/Mahatma_Gandhi> dbpedia-owl:birthDate ?birthDate;
dbpedia-owl:birthName ?name;
dbpedia-owl:restingPlace ?restingPlace;
dbpedia-owl:deathDate ?deathDate
 }

http://dbpedia.org/sparql上试试 (direct link)

如果你要查询其他资源我建议你这样

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}
}

答案 1 :(得分:1)

您可以通过一个请求提取有关甘地的所有数据:

describe <http://dbpedia.org/resource/Mahatma_Gandhi>

并选择结果格式。