How to query DBPedia data for a given Wikipedia URL?

纵然是瞬间 提交于 2019-12-11 10:55:58

问题


If I want to query the RDF for Appomattox Court House National Historical Park in DBPedia, what's the query string if I search by wiki page URL?

I tested the following string but get no result:

select ?building 
where {
   ?building a dbo:Building .
   ?building foaf:primaryTopic <http://en.wikipedia.org/wiki/Appomattox_Court_House_National_Historical_Park>
} LIMIT 100

回答1:


As said in my comment as well: the problem is that you are using the foaf:primaryTopic relation the wrong way around. The wiki page is the subject of the relation, and the DBPedia resource the object value. So it should be this:

SELECT ?building 
WHERE {
    ?building a dbo:Building .
    <http://en.wikipedia.org/wiki/Appomattox_Court_House_National_Historical_Park> foaf:primaryTopic ?building .
} 
LIMIT 100

Alternatively, as @AKSW commented, you can use the inverse relation, which is called foaf:isPrimaryTopicOf:

SELECT ?building 
WHERE {
    ?building a dbo:Building .
    ?building foaf:isPrimaryTopicOf <http://en.wikipedia.org/wiki/Appomattox_Court_House_National_Historical_Park> .
} 
LIMIT 100


来源:https://stackoverflow.com/questions/32935461/how-to-query-dbpedia-data-for-a-given-wikipedia-url

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!