System.out.println( "\nResults after applying changes through OWL API" );
System.out.println( "----------------------------------------------" );
// read the ontology
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLDataFactory factory = manager.getOWLDataFactory();
OWLOntology ontology = manager.loadOntology( IRI.create( mindswappers ) );
// we want a non-buffering reasoner here (a buffering reasoner would not process any additions, until manually refreshed)
PelletReasoner reasoner = com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory.getInstance().createNonBufferingReasoner( ontology );
manager.addOntologyChangeListener( reasoner );
// perform initial consistency check
long s = System.currentTimeMillis();
boolean consistent = reasoner.isConsistent();
long e = System.currentTimeMillis();
System.out.println( "Consistent? " + consistent + " (" + (e - s) + "ms)" );
// peform ABox addition which results in a consistent KB
OWLClass concept = factory.getOWLClass( IRI.create( mindswap + "GraduateStudent" ) );
OWLNamedIndividual individual = factory
.getOWLNamedIndividual( IRI.create( mindswappers + "JohnDoe" ) );
manager.applyChange( new AddAxiom( ontology, factory.getOWLClassAssertionAxiom( concept, individual ) ) );
// perform incremental consistency check
s = System.currentTimeMillis();
consistent = reasoner.isConsistent();
e = System.currentTimeMillis();
System.out.println( "Consistent? " + consistent + " (" + (e - s) + "ms)" );
// peform ABox addition which results in an inconsistent KB
OWLObjectProperty role = factory.getOWLObjectProperty( IRI.create( foaf + "mbox" ) );
individual = factory.getOWLNamedIndividual( IRI.create( mindswappers + "Christian.Halaschek" ) );
OWLNamedIndividual mbox = factory.getOWLNamedIndividual( IRI.create( "mailto:kolovski@cs.umd.edu" ) );
manager.applyChange( new AddAxiom( ontology, factory.getOWLObjectPropertyAssertionAxiom(
role, individual, mbox ) ) );
// perform incremental consistency check
s = System.currentTimeMillis();
consistent = reasoner.isConsistent();