// Get an instance of the incremental classifier
IncrementalClassifier classifier = new IncrementalClassifier( ontologyTBox );
// We need some timing to show the performance of the classification
Timers timers = new Timers();
// We classify the ontology and use a specific timer to keep track of
// the time required for the classification
Timer t = timers.createTimer( "First classification" );
t.start();
classifier.classify();
t.stop();
System.out.println( "\nClassification time: " + t.getTotal() + "ms");
System.out.println( "Subclasses of " + pain + ": " + classifier.getSubClasses( pain, true ).getFlattened() + "\n");
// Now create a new OWL axiom, subClassOf(Headache, Pain)
OWLAxiom axiom = OWL.subClassOf( headache, pain );
// Add the axiom to the ontology, which creates a change event
OWL.manager.applyChange( new AddAxiom( ontologyTBox, axiom ) );
// Now we create a second timer to keep track of the performance of the
// second classification
t = timers.createTimer("Second classification");
t.start();
classifier.classify();
t.stop();
System.out.println( "\nClassification time: " + t.getTotal() + "ms");
System.out.println( "Subclasses of " + pain + ": " + classifier.getSubClasses( pain, true ).getFlattened() + "\n");
// Remove the axiom from the ontology, which creates a change event
OWL.manager.applyChange( new RemoveAxiom( ontologyTBox, axiom ) );
// Now we create a third timer to keep track of the performance of the
// third classification
timers.startTimer( "Third classification" );
classifier.classify();
timers.stopTimer( "Third classification" );
System.out.println( "\nClassification time: " + t.getTotal() + "ms");
System.out.println( "Subclasses of " + pain + ": " + classifier.getSubClasses( pain, true ).getFlattened() + "\n");
// Finally, print the timing. As you can see, the second classification
// takes significantly less time, which is the characteristic of the
// incremental classifier.
System.out.println( "Timers summary" );
for( Timer timer : timers.getTimers() ) {
if( !timer.isStarted() )
System.out.println( timer.getName() + ": " + timer.getTotal() + "ms" );
}
}