Reasoner Example

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Reasoner Example

Rajverma

Hi List,

 

At http://protege.stanford.edu/plugins/owl/api/ReasonerAPIExamples.html it is mentioned that we can also classify the entire ontology once and then query the local ontology instead of calling the external DIG reasoner through http for every query… The following code, given in the above link, should do this job, right!

 

// We can also classify the whole ontology, which will put the 
// inferred class hierarchy information directly into the Protege-OWL 
// model. 
System.out.println("Classifying taxonomy..."); 
reasoner.classifyTaxonomy(null); 
System.out.println("...Classified taxonomy!"); 
// We can then use the methods on OWLNamedClass for getting inferred 
// information, without having to make separate queries to the external 
// DIG reasoner. 
System.out.println("Inferred subclasses of VegetarianPizza:"); 
inferredSubclasses = vegetarianPizza.getInferredSubclasses(); 
for(Iterator it = inferredSubclasses.iterator(); it.hasNext();) { 
    OWLNamedClass curClass = (OWLNamedClass) it.next(); 
    System.out.println(curClass.getName()); 
}

 

However, from this example if I comment the following lines,

 

                    // Now get the inferred subclasses of VegetarianPizza

//                    Collection inferredSubclasses = reasoner.getDescendantClasses(vegetarianPizza, null);

//                    System.out.println("Number of inferred VegetarianPizzas: " + inferredSubclasses.size());

//                    System.out.println("VegetarianPizzas:");

//                    for(Iterator it = inferredSubclasses.iterator(); it.hasNext();) {

//                        OWLNamedClass curClass = (OWLNamedClass) it.next();

//                        System.out.println(curClass.getName());

//                    }

 

Then I get errors in my code, which says that the inferredSubclasses cannot be resolved… when I uncomment the line:

 

Collection inferredSubclasses = reasoner.getDescendantClasses(vegetarianPizza, null);

 

it then works fine… so my question is, when we can query the classified ontology with the second method (without having to call the external reasoner) then why do we need this call to the reasoner for inferredSubclasses? Why is the second method dependent on this particular line?

 

 

Thanx,

Raj