I'm currently looking for a way to query DBPedia's Infobox Onyology database via the SPARQL endpoint to get a list of the classes, the subclasses of a selected class, and the properties of a given class. As far as I've been able to find, you either need to know the property that you are looking for or search for something specific - all the examples I've found seem predicated on the idea that you would want to search for something specific (like populations of cities above a certain elevation, etc), whereas I'd like to build something where I can effectively "browse" the categories. For example, starting with the list of subclasses of "owl:Thing" on this class hierarchy chart and presenting the user with the list of subclasses of a selected subclass. It seems possible to browse something like this via the mappings wiki, but it would be preferable to query the SPARQL endpoint directly.
Is there some simple SPARQL query that would return the available classes and properties of those classes?
Update: I've come up with a way to get the class hierarchy it seems, by iterating through this query:
SELECT ?subject WHERE {
?subject rdfs:subClassOf owl:Thing
}
Which returns a list of subclasses of owl:Thing, and if I replace owl:Thing with one of the subclasses, I get the list of subclasses of that, until there are no subclasses, at which point I can select all the resources which have a type given by the chosen subclass. I'm still not quite sure how to get all the properties common to the subclass, though.
Update 2 Getting closer now. This query gets me all the properties (children of dbpedia:property) that are also a country, as well as their titles:
SELECT DISTINCT ?prop ?title WHERE {
?country ?prop ?value.
?country a <http://dbpedia.org/ontology/Country>.
?prop rdf:type rdf:Property.
?prop rdfs:label ?title
}
Which is actually all I really asked for. The last thing I'm trying to do now is to try to order these by the number of pages in which they appear (presumably the most common properties will be the ones of greatest interest).