检查 ontology 与 OWL API 的一致性和可满足性 4

Check ontology consistency & satisifiability with OWL API 4

我正在尝试检查 ontology 的一致性。 ontology 仅包含个体的描述,class 和语义规则由导入的 ontology.

描述

我认为使用 isConsistenct 方法是正确的选择。

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";
    } 

检查 ontology 一致性的正确方法是什么,就像启动推理机时应用 Protege 5 一样?


使用 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;

Protege 也在使用某种isConsistent 方法。根据您所指的版本,此方法要么由开发人员内置,要么使用在 OWL API 中开发的方法。例如,如果需要,请查看 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 以了解差异。要点是:

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.

如果你想找到不可满足的类,你只需要在所有类上调用isSatisfiable方法:

reasoner.isSatisfiable(className);

该方法是正确的,但 StructuralReasonerFactory 的使用是一个问题。该推理机不进行真正的推理,它仅使用断言的公理来回答一些基本问题。它无法检查一致性。

您需要使用真正的推理机来进行一致性检查。已经有一些推理机支持 OWLAPI 4,参见 https://github.com/owlcs/owlapi/wiki