Retrieving common Classes' attributes from DBPedia with SPARQL

橙三吉。 提交于 2019-12-11 09:58:12

问题


I'm trying to retrieve some properties for certain classes in dbpedia. Consider you have a country. It does exist in the ontology but I want to retrieve some related common properties, like name, currency, time zone, etc. But there is no such information in http://dbpedia.org/ontology/Country.

SELECT *                
WHERE {                        
  <http://dbpedia.org/ontology/Country> ?predicate ?object.         
} 

And it is logic. The query just return 15 matchings, and even wikipedia does not have such information (see https://en.wikipedia.org/wiki/Country ). But if you enter a concrete country, lets say Brasil, you can see such information in Wikipedia. And here I have two problems:

1) I can't access such data from dbpedia. I tryed:

SELECT * WHERE {
   <http://dbpedia.org/resource/Brasil> ?prop ?label.
}

2) I need the common properties of most of the countries. In fact, what I need are the properties of the class, not the values of the instances. E.g. I don't need to retrieve "Brasil", "Uruguay" or "Argentina", but "name". I don't need to retrieve "Real", "Uruguayan peso" or "Peso", but "Currency".

Any clue where I should look?


回答1:


It seems what you really want is all of the instances of Country, so the initial query would be:

SELECT ?country
WHERE {
    ?country a <http://dbpedia.org/ontology/Country>
}

To get the common properties for Countries in DBPedia, try:

SELECT DISTINCT ?p
WHERE {
    ?country a <http://dbpedia.org/ontology/Country> .
    ?country ?p ?o .
}


来源:https://stackoverflow.com/questions/35446323/retrieving-common-classes-attributes-from-dbpedia-with-sparql

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