calendarw
calendarw

Reputation: 1511

How to query DBPedia data for a given Wikipedia URL?

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

Upvotes: 2

Views: 1247

Answers (1)

Jeen Broekstra
Jeen Broekstra

Reputation: 22042

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

Upvotes: 2

Related Questions