Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieving all the ancestors of a rdf:Class

Imagine the following Taxonomy (acyclic & directed graph):

<my:Eukaryota> <rdfs:subClassOf> <my:Organism>.
<my:Mammal> <rdfs:subClassOf> <my:Eukaryota>.
<my:Primate> <rdfs:subClassOf> <my:Mammal>.
<my:HomoSapiens> <rdfs:subClassOf> <my:Primate>.
<my:Bacteria> <rdfs:subClassOf> <my:Organism>.
<my:Escherichia> <rdfs:subClassOf> <my:Bacteria>.

1) Is it possible with the Jena OWL API to check if a given resource (e.g. HomoSapiens) is a subclass of 'Mammal' without recursively retrieving all the parents nodes ?

2) The same question with SPARQL.

Thanks

like image 680
Pierre Avatar asked Sep 22 '09 07:09

Pierre


1 Answers

If you're already using Jena, you can use use Pellet's SPARQL-DL query engine, which should let you query individuals in an ontology-aware way.

Alternately, you can use Jena's InfModel instead of Model interface, attach a reasoner (and ontology) to it, and then run the query RobV mentions. You can use Pellet's reasoner for this if you wanted. You don't need to use the OntModel if you just want to do reasoning.

like image 103
Phil M Avatar answered Sep 19 '22 14:09

Phil M