[英]OWLAPI : HermiT reasoner shows incorrect result and NO explanation
我有通過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推理器沒有產生任何解釋 。 (需要什么才能得到解釋?)
Q2。 另外,推理給出的Entailed在下列情況下,一些事實/斷言-
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>)
[在Ontology中提供]
我想獲得像protege一樣的數據。 Protege分別顯示推斷的公理及其解釋。 那么如何獲得它們? (我添加了一些protege的屏幕截圖供參考)
我的本體論:
蘊涵說明:
你在解釋生成器上使用了錯誤的方法:我的意思是,你打電話
Set<Set<OWLAxiom>> expl = multExplanator.getExplanations(ax.getSuperClass());
但是,如果你只提供一個類別,你為什么認為這會給出一個公理的解釋。 班級表達? 看看Javadoc,它說你調用的方法
“返回給定不滿足類的所有解釋。”
這只是公理SubClassOf(CE, owl:Nothing)
的便捷方法,即CE
類不可滿足。 在OWL中,您可以通過公理進行陳述,而這些是唯一可以真實的。 堅持,從而被引入。 簡而言之,您必須使用子類公理並將其轉換為類表達式,然后對其進行不可滿足性測試:
A SubClassOf B => A and not B
有一個轉換器類可以為您執行任何OWL公理:
com.clarkparsia.owlapi.explanation.SatisfiabilityConverter::convert(OWLAxiom axiom)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.