问题
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