user1615337
user1615337

Reputation: 11

SPARQL- Retrieving a DBPedia resource by category string

How can I obtain DBpedia resources based on a Wikipedia category? For example, all Japan's islands that have been flooded. A list of possible categories candidates related to "Flood" include:

I couldn't navigate using SPARQL queries from categories to certain resources.

Upvotes: 1

Views: 460

Answers (1)

Joshua Taylor
Joshua Taylor

Reputation: 85813

One of the easiest ways to figure out what SPARQL query to write against DBpedia is to find a Wikipedia with some of the information that you want, then examine the DBpedia resource corresponding to it, and then constructing the query based on that. For instance, there is a Wikipedia article, 1993 Kagoshima Heavy Rain. Based on the naming convention, this leads us to the DBpedia resource http://dbpedia.org/resource/1993_Kagoshima_Heavy_Rain. Browsing this, we can see how the article is related to the category Floods in Japan. Particularly, we see that the data contains the following triple:

dbpedia:1993_Kagoshima_Heavy_Rain dcterms:subject category:Floods_in_Japan

This suggests that we try putting the following query into the DBpedia SPARQL Endpoint:

SELECT * WHERE {
  ?event dcterms:subject category:Floods_in_Japan .
}

SPARQL results

There are two results:

event
http://dbpedia.org/resource/1953_North_Kyushu_Flood
http://dbpedia.org/resource/1993_Kagoshima_Heavy_Rain

To answer your particular question, you'll have to dig a bit more into the data to find the properties and resources that you need, but you'll follow the same general process.

Upvotes: 2

Related Questions