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