我有以下通过 Protege 创建的本体。

本体 :

<?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 -->

我想运行 HermiT 推理器来获得推断的类层次结构及其解释。

以下是我的 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();

我的 输出 上面的代码是:
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。 HermiT reasoner 没有生成任何解释。 (需要什么来获得解释吗?)

Q2。在以下情况下,推理者还提供了一些事实/断言作为 包含的 -

1) SubClassOf(<http://www.semanticweb.org/ontologies/reasoner#A> <http://www.semanticweb.org/ontologies/reasoner#B>) 【本体提供】

2) SubClassOf(<http://www.semanticweb.org/ontologies/reasoner#B> <http://www.semanticweb.org/ontologies/reasoner#C>) 【本体提供】

我想像 protege 一样获取数据。 Protege 分别展示了推断的公理及其解释。那么如何获得它们呢?
(我添加了一些protege的屏幕截图以供引用)

我的本体:

java - OWLAPI : HermiT reasoner shows incorrect result and NO explanation-LMLPHP

蕴涵说明:

java - OWLAPI : HermiT reasoner shows incorrect result and NO explanation-LMLPHP

最佳答案

您在解释生成器上使用了错误的方法:我的意思是,您调用

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

但是,如果您只提供一个类,为什么您认为这会为公理提供解释?类(Class)表达?看看Javadoc,它说你调用的方法

“返回给定不可满足类的所有解释。”

这只是公理 SubClassOf(CE, owl:Nothing) 的一种便利方法,即类 CE 是不可满足的。
在 OWL 中,您可以通过公理进行陈述,而这些是唯一可以真实的事物。持有,因此被包含。简而言之,您必须使用子类公理并将其转换为类表达式,然后将对其进行不可满足性测试:
A SubClassOf B => A and not B
有一个转换器类可以为您完成任何 OWL 公理:
com.clarkparsia.owlapi.explanation.SatisfiabilityConverter::convert(OWLAxiom axiom)

关于java - OWLAPI : HermiT reasoner shows incorrect result and NO explanation,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/38524465/

10-11 20:42