简体   繁体   English

OWLAPI:HermiT推理器显示错误的结果,没有解释

[英]OWLAPI : HermiT reasoner shows incorrect result and NO explanation

I have following ontology created through Protege. 我有通过Protege创建的跟随本体。

Ontology : 本体论

<?xml version="1.0"?>
<!DOCTYPE rdf:RDF [
    <!ENTITY owl "http://www.w3.org/2002/07/owl#" >
    <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
    <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
    <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
]>
<rdf:RDF xmlns="http://www.semanticweb.org/ontologies/reasoner#"
     xml:base="http://www.semanticweb.org/ontologies/reasoner"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:owl="http://www.w3.org/2002/07/owl#"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
    <owl:Ontology rdf:about="http://www.semanticweb.org/ontologies/reasoner"/>
    <!-- 
    ///////////////////////////////////////////////////////////////////////////////////////
    //
    // Object Properties
    //
    ///////////////////////////////////////////////////////////////////////////////////////
     -->
    <!-- http://www.semanticweb.org/ontologies/reasoner#myProp -->
    <owl:ObjectProperty rdf:about="http://www.semanticweb.org/ontologies/reasoner#myProp"/>
    <!-- 
    ///////////////////////////////////////////////////////////////////////////////////////
    //
    // Classes
    //
    ///////////////////////////////////////////////////////////////////////////////////////
     -->
    <!-- http://www.semanticweb.org/ontologies/reasoner#A -->

    <owl:Class rdf:about="http://www.semanticweb.org/ontologies/reasoner#A">
        <rdfs:subClassOf rdf:resource="http://www.semanticweb.org/ontologies/reasoner#B"/>
    </owl:Class>
    <!-- http://www.semanticweb.org/ontologies/reasoner#B -->
    <owl:Class rdf:about="http://www.semanticweb.org/ontologies/reasoner#B">
        <rdfs:subClassOf rdf:resource="http://www.semanticweb.org/ontologies/reasoner#C"/>
        <rdfs:subClassOf>
            <owl:Class>
                <owl:intersectionOf rdf:parseType="Collection">
                    <rdf:Description rdf:about="http://www.semanticweb.org/ontologies/reasoner#D"/>
                    <owl:Restriction>
                        <owl:onProperty rdf:resource="http://www.semanticweb.org/ontologies/reasoner#myProp"/>
                        <owl:someValuesFrom rdf:resource="http://www.semanticweb.org/ontologies/reasoner#A"/>
                    </owl:Restriction>
                </owl:intersectionOf>
            </owl:Class>
        </rdfs:subClassOf>
    </owl:Class>
    <!-- http://www.semanticweb.org/ontologies/reasoner#C -->
    <owl:Class rdf:about="http://www.semanticweb.org/ontologies/reasoner#C">
        <owl:equivalentClass rdf:resource="http://www.semanticweb.org/ontologies/reasoner#D"/>
    </owl:Class>
    <!-- http://www.semanticweb.org/ontologies/reasoner#D -->
    <owl:Class rdf:about="http://www.semanticweb.org/ontologies/reasoner#D"/>
</rdf:RDF>
<!-- Generated by the OWL API (version 3.5.1) http://owlapi.sourceforge.net -->

I want to run HermiT reasoner to get inferred class hierarchy along with its explanation . 我想运行HermiT推理器来获得推断类层次结构及其解释

Following is my JAVA code : 以下是我的JAVA代码

//Some work done before to load the ontology into OWLOntologyManager
Configuration reasonerConf = new Configuration();
reasonerConf.throwInconsistentOntologyException = false;
ReasonerFactory factory = new ReasonerFactory();
OWLReasoner reasoner = factory.createReasoner(owlOntology, reasonerConf); // owlOntology : Current working Ontology
BlackBoxExplanation exp = new BlackBoxExplanation(owlOntology, factory, reasoner);
HSTExplanationGenerator multExplanator = new HSTExplanationGenerator(exp);
InferredSubClassAxiomGenerator ge = new InferredSubClassAxiomGenerator();
Set<OWLSubClassOfAxiom> subss = ge.createAxioms(dataFactory, reasoner); // dataFactory : OWLDataFactory
System.out.println("\nSubClassAxiom in reasoner :- ");
for (OWLSubClassOfAxiom ax : subss) {
    System.out.println("\nAxiom :- " + ax);
    System.out.println(ax.getSuperClass());
    System.out.println(ax.getSubClass());
    System.out.println("Is Axiom Entailed ? :- " + reasoner.isEntailed(ax));
    Set<Set<OWLAxiom>> expl = multExplanator.getExplanations(ax.getSuperClass());
    System.out.println("Explanation Set size :- " + expl.size());
}
reasoner.dispose();

My output for above code is : 上面代码的输出是:

SubClassAxiom in reasoner :- 

Axiom :- SubClassOf(<http://www.semanticweb.org/ontologies/reasoner#C> owl:Thing)
owl:Thing
<http://www.semanticweb.org/ontologies/reasoner#C>
Is Axiom Entailed ? :- true
Explanation Set size :- 0

Axiom :- SubClassOf(<http://www.semanticweb.org/ontologies/reasoner#B> <http://www.semanticweb.org/ontologies/reasoner#C>)
<http://www.semanticweb.org/ontologies/reasoner#C>
<http://www.semanticweb.org/ontologies/reasoner#B>
Is Axiom Entailed ? :- true
Explanation Set size :- 0

Axiom :- SubClassOf(<http://www.semanticweb.org/ontologies/reasoner#B> <http://www.semanticweb.org/ontologies/reasoner#D>)
<http://www.semanticweb.org/ontologies/reasoner#D>
<http://www.semanticweb.org/ontologies/reasoner#B>
Is Axiom Entailed ? :- true
Explanation Set size :- 0

Axiom :- SubClassOf(<http://www.semanticweb.org/ontologies/reasoner#D> owl:Thing)
owl:Thing
<http://www.semanticweb.org/ontologies/reasoner#D>
Is Axiom Entailed ? :- true
Explanation Set size :- 0

Axiom :- SubClassOf(<http://www.semanticweb.org/ontologies/reasoner#A> <http://www.semanticweb.org/ontologies/reasoner#B>)
<http://www.semanticweb.org/ontologies/reasoner#B>
<http://www.semanticweb.org/ontologies/reasoner#A>
Is Axiom Entailed ? :- true
Explanation Set size :- 0

Q1 . Q1。 There are no explanations generated by HermiT reasoner. HermiT推理器没有产生任何解释 (Anything needed to get the explanations ?) (需要什么才能得到解释?)

Q2 . Q2。 Also the reasoner gives some facts/assertions as Entailed in following cases - 另外,推理给出的Entailed在下列情况下,一些事实/断言-

1) SubClassOf(<http://www.semanticweb.org/ontologies/reasoner#A> <http://www.semanticweb.org/ontologies/reasoner#B>) [Provided in Ontology] 1) SubClassOf(<http://www.semanticweb.org/ontologies/reasoner#A> <http://www.semanticweb.org/ontologies/reasoner#B>) [在Ontology中提供]

2) SubClassOf(<http://www.semanticweb.org/ontologies/reasoner#B> <http://www.semanticweb.org/ontologies/reasoner#C>) [Provided in Ontology] 2) SubClassOf(<http://www.semanticweb.org/ontologies/reasoner#B> <http://www.semanticweb.org/ontologies/reasoner#C>) [在Ontology中提供]

I want to get data just like protege. 我想获得像protege一样的数据。 Protege shows inferred axioms separately along with their explanations. Protege分别显示推断的公理及其解释。 So how to get them ? 那么如何获得它们? (I have added some screen shots of protege for reference) (我添加了一些protege的屏幕截图供参考)

My Ontology: 我的本体论:

在此输入图像描述

Explanation for entailment: 蕴涵说明:

在此输入图像描述

You are using the wrong method on the explanation generator: I mean, you call 你在解释生成器上使用了错误的方法:我的意思是,你打电话

Set<Set<OWLAxiom>> expl = multExplanator.getExplanations(ax.getSuperClass());

But why do you think this gives back explanations for an axiom if you provide only a class resp. 但是,如果你只提供一个类别,你为什么认为这会给出一个公理的解释。 class expression? 班级表达? Having a look at the Javadoc, it says that the method you called 看看Javadoc,它说你调用的方法

"Returns all the explanations for the given unsatisfiable class." “返回给定不满足类的所有解释。”

This is just a convenience method for the axiom SubClassOf(CE, owl:Nothing) , ie that the class CE is unsatisfiable. 这只是公理SubClassOf(CE, owl:Nothing)的便捷方法,即CE类不可满足。 In OWL you can make statements via axioms, and those are the only thing that can be true resp. 在OWL中,您可以通过公理进行陈述,而这些是唯一可以真实的。 hold, and thus being entailed. 坚持,从而被引入。 Shortly said, you have to use the subclass axiom and convert it into a class expression which will then be tested for unsatisfiability: 简而言之,您必须使用子类公理并将其转换为类表达式,然后对其进行不可满足性测试:

A SubClassOf B => A and not B

There is a converter class that does it for you for any OWL axiom: 有一个转换器类可以为您执行任何OWL公理:

com.clarkparsia.owlapi.explanation.SatisfiabilityConverter::convert(OWLAxiom axiom)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM