Search code examples
rdfsparqlsemanticsdbpedia

How to differentiate between a Thing and an inanimate object with SPARQL


Using SPARQL, I can get all related info about some resource quite easily, but I'm having a hard time figuring out how to actually differentiate between things and things -- in which Thing is the super class of all classes, and things that are inanimate objects, like a cup, spoon, pencil, etc.

For example, here are a few innanimate objects in DBPedia:

Here's the thing -- I know that a lot of ontologies don't have a specific type that would easily give you the ability to query for objects, however, perhaps theres a way to tell if something is a thing because it has no subclasses, or maybe the property path of its types can be used to differentiate in some roundabout way.

But, in general, I'd like to know if it is possible to differentiate between Things and things using a SPARQL query? and if so, how?


Solution

  • You can browse the DBpedia ontology classes online. Under owl:Thing, there are a number of toplevel classes. While it's not a perfect match, because it includes some collective entities, it looks like the Agent class and its complement probably correspond fairly well to animate and inanimate objects. You might also need to consider the Animal class as well, or some other things under the Species class. There are also some non-DBpedia classes, e.g., foaf:Person that you should probably consider, too. At any rate, the big approach here would be to select what classes in that hierarchy you consider to represent animate and inanimate things, and then use that to decide about instances.

    E.g., you could use a query like this to find animate things (if we define animate things as Agents and Animals):

    select ?x where { 
      ?x a owl:Thing 
      filter exists {
        ?x a ?type .
        filter( ?type in ( dbpedia-owl:Agent, dbpedia-owl:Animal ) )
      }
    }
    limit 100 
    

    SPARQL results