Check ontology consistency & satisifiability with OWL API 4

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-08 11:18:26

问题


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;

回答1:


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




回答2:


Protege is also using some sort of isConsistent method. Depending on which version you are referring to, this method either is built in by the developers or used the one that is developed in OWL API. For example, look at this. However, when you run the reasoner in Protege, both the inConsistent and isSatisfiable methods are fired. So what you see is the result of two actions. Read the following blog post for understanding the difference if you need. The gist is:

So, while we can have unsatisfiable classes in a consistent ontology, all classes in an inconsistent ontology are unsatisfiable because an inconsistent ontology simply has no model, and thus it can’t have one with instances of any given class.

If you want to find the unsatisfiable classes, you just need to call the isSatisfiable method on all the classes:

reasoner.isSatisfiable(className);


来源:https://stackoverflow.com/questions/30890587/check-ontology-consistency-satisifiability-with-owl-api-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!