Getting DBPedia Infobox categories

后端 未结 4 1516
半阙折子戏
半阙折子戏 2021-01-02 18:41

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

4条回答
  •  轮回少年
    2021-01-02 19:29

    OK, so I've actually figured out more or less exactly how to do this, so I'm submitting this as an answer rather than just an edit. What seems to give me exactly what I'm looking for is to start by iterating through the class heirarchy using this query:

    SELECT ?class ?label WHERE {
         ?class rdfs:subClassOf owl:Thing.
         ?class rdfs:label ?label. 
         FILTER(lang(?label) = "en")
    }
    

    Feeding the selected result into the query in place of owl:Thing each time.

    Once the user has selected the lowest-level class that they'd like, to display a list of properties, in descending order by the number of entries in which they appear, I use this query:

    SELECT ?prop ?title WHERE {
         ?country ?prop [].
         ?country a .
         ?prop rdf:type rdf:Property.
         ?prop rdfs:label ?title
    } ORDER BY DESC(COUNT(DISTINCT ?country))
    

    Of course, if you actually look at those results, there are some funky properties there that don't have very descriptive labels ("s"? What?), but this is at least what I was looking for in the first place.

提交回复
热议问题