【问题标题】:OWLAPI : HermiT reasoner shows incorrect result and NO explanationOWLAPI:HermiT 推理器显示不正确的结果并且没有解释
【发布时间】:2016-07-22 10:44:17
【问题描述】:

我通过 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

第一季度。 HermiT reasoner 没有解释。 (有什么需要解释的吗?)

第二季度。此外,推理者在以下情况下给出了一些事实/断言作为相关 -

1)SubClassOf(&lt;http://www.semanticweb.org/ontologies/reasoner#A&gt; &lt;http://www.semanticweb.org/ontologies/reasoner#B&gt;)【本体提供】

2) SubClassOf(&lt;http://www.semanticweb.org/ontologies/reasoner#B&gt; &lt;http://www.semanticweb.org/ontologies/reasoner#C&gt;) [本体提供]

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

我的本​​体:

蕴涵解释:

【问题讨论】:

    标签: java owl ontology protege owl-api


    【解决方案1】:

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

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

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

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

    这只是公理SubClassOf(CE, owl:Nothing) 的一种方便方法,即类CE 是不可满足的。 在 OWL 中,您可以通过公理做出陈述,而这些是唯一可以成为真实的东西。持有,因此被包含。简而言之,您必须使用子类公理并将其转换为类表达式,然后对其进行不可满足性测试:

    A SubClassOf B =&gt; A and not B

    有一个转换器类可以为您处理任何 OWL 公理:

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

    【讨论】:

    • 刚刚得到我第一个问题的答案。如何区分本体中的公理和推理器所包含的公理?
    • 只需删除本体中包含的公理:owlOntology.getAxioms() 或仅用于子类公理owlOntology.getAxioms(AxiomType.SUBCLASS_OF) 请参阅 Javadoc 和 OWL API 示例。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多