I'm trying to check an ontology for its consistency. The ontology includes only descriptions of individuals, the class and semantic rules are described by an imported ontology.
I thougt using the isConsistenct method would be the right choice.
OWLReasonerFactory reasonerFactory = new StructuralReasonerFactory();
OWLReasoner reasoner = reasonerFactory.createNonBufferingReasoner(mergedOntology);
if(reasoner.isConsistent()){
return "Merged ontology PASSED the consistency test";
}else{
return "Ontology FAILED the consistency test";
}
What would be the correct approach to check the ontology's consistency, like Protege 5 applies when starting a reasoner?
Code update using Pellet
OWLReasonerFactory reasonerFactory = new PelletReasonerFactory();
OWLReasoner reasoner = reasonerFactory.createNonBufferingReasoner(mergedOntology);
String answer = "";
if(reasoner.isConsistent()){
if(reasoner.getUnsatisfiableClasses().getEntitiesMinusBottom().size()>0){
answer = "Merged ontology FAILED satisfiability test. Unsatisfiable classes detected: " + reasoner.getUnsatisfiableClasses().getEntitiesMinusBottom().size();
}
answer = "Merged ontology PASSED the consistency test";
}else{
answer = "Merged ontology FAILED the consistency test, please review the Axioms or debug using Protege";
//FYI an example how to implement a working debugger can be found on sourceforge's OWL API page under Debugger
}
reasoner.dispose();
return answer;
The approach is right but the use of the StructuralReasonerFactory is an issue. That reasoner does no real reasoning, it merely uses asserted axioms to answer some basic queries. It cannot check consistency.
You need to use a real reasoner to carry out the consistency check. There are a few reasoners already supporting OWLAPI 4, see https://github.com/owlcs/owlapi/wiki