Search code examples
rdfsemantic-webdbpedialinked-data

Enumerating "type" properties used in DBpedia?


Given a random set of DBpedia resources (objects), I'd like to get all their types, e.g. resources they are related to with ANY KIND of type-relationship. Therefore, I want to identify that kind of property, i.e., all kinds of type-properties. I've found these so far:

- http://dbpedia.org/ontology/type
- dbpedia-owl:wikiPageRedirects*/dbpedia-owl:type //in case of a redirect
- http://dbpedia.org/property/wordnet_type
- http://dbpedia.org/property/type
- http://www.w3.org/1999/02/22-rdf-syntax-ns#type

How can I find all the cases I have to cover? (All type-properties, all redirect possibilities...?) Is there some structure behind this, and where would I start looking?


Solution

  • So how do I find all the cases I have to cover? (All type-properties, all redirect possibilities...?) Is there some structure behind this / where would I start looking?

    Unless you have some criteria for defining what is and what isn't a type property, then you're not really going to have much luck in this. If you just wanted, e.g., all the properties that end with type, then you could use a query like:

    select distinct ?p where {
      [] ?p []
      filter strends(str(?p), "type") 
    }
    

    but that won't actually get you everything in the case of DBpedia, probably because it hits some internal time limit. However, for some given resources, you can provide the value of the subject that you care about, and get the results just for the given resources. E.g,.

    select distinct ?p where {
      dbpedia:Mount_Monadnock ?p []
      filter strends(str(?p), "type") 
    }
    limit 100
    

    SPARQL results

    p
    http://www.w3.org/1999/02/22-rdf-syntax-ns#type
    http://dbpedia.org/ontology/type
    http://dbpedia.org/property/type
    http://dbpedia.org/property/wordnet_type
    

    Of course, you probably want the values, too:

    select distinct ?p ?type where {
      dbpedia:Mount_Monadnock ?p ?type
      filter strends(str(?p), "type") 
    }
    

    SPARQL results

    What you've said in:

    - http://dbpedia.org/ontology/type
    - dbpedia-owl:wikiPageRedirects*/dbpedia-owl:type //in case of a redirect
    

    is actually a bit misleading. dbpedia-owl:type is the property http://dbpedia.org/ontology/type, it's just written using the dbpedia-owl: prefix. If you're concerned about redirects, you'd be concerned about redirects for all the resources and their properties, not just dbpedia-owl:type. That is, you'd use a query like

    select distinct ?p ?type where {
      dbpedia:Mount_Monadnock dbpedia-owl:wikiPageRedirects* ?actualThing .
      ?actualThing ?p ?type .
      filter strends(str(?p), "type") 
    }