Ontology Inferencing Exercise using Jena

Case I: Print the super classes of a given class

Using theJena reasoner, one can query for the super classes of a given class. The query using Jena APIs is basically find all classes that have the relation ‘ the given class. In other words we are trying to find out the class of which the given class is a ‘subClassOf’. The reasoner will infer from this query and give all the parents for the given class in the taxanomy as shown in the output for

- ( rdfs:subClassOf owl:Thing)

- ( rdfs:subClassOf

- ( rdfs:subClassOf rdfs:Resource)

- ( rdfs:subClassOf

- ( rdfs:subClassOf

- ( rdfs:subClassOf

Case II: Determine if given entity is instance of a given class

The query model that I used is similar to the super class problem except that the relation that I am looking for is ‘ The logic is that for a given entity get the class of which it is type and then check if the class, matches the class that is to be compared. If it matches then the given entity is an instance of the given class. The classes returned are a list of classes and even if there is a match for anyone of them in the list, then the class-instance relation is determined.

The output for the following pair: ‘ and ‘ is

is an instance of

The point worth noting is that ‘Kinlin’ is an instance of ‘Hotel’. But since ‘Hotel’ is a subclass of ‘ServingPoint’, the reasoner can infer that it is an instance of ‘ServingPoint’.

Case III: Determine if two given classes have same parent

The problem is to determine if two classes have any common parent in the taxonomy. If we extend this idea to general sense then two classes may have some common parent somwehere in the taxanomy, even when they don’t have immediate parents that are common. Thus an Inferencing engine should be able to trace taxonomically common parents and not just get restricted by immediate ones. However, any class in OWL will always be a subclass of ‘owl:Resource’ and ‘rdfs:Thing’ an ditself. Thus, any two classes will always have common parent. Thus, the logic that I have used is to find a list of parents for a given class, neglecting the three parent classes mentioned above. Do same thing with other class an dthe compare this list. If any oarent match then we have found the common parent.

The output for the following pair: ‘ and ‘

The Parents for ‘ and for ‘ are same

Again, important point to observe is that these two classes don’t have same immediate parent but if we trace up the taxonomy then they do share the same grandparent ‘Vegetarian’.