![](/img/trans.png)
[英]OWLAPI : HermiT reasoner thows “UnsupportedDatatypeException” for data type from imported Ontology
[英]OWLAPI : Want to get inferred axioms from ontology using HermiT reasoner
我想從推理器[ HermiT ]得到推斷的公理及其正確的解釋。 我有以下本體創建的保護。
A.owl
<?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/A#"
xml:base="http://www.semanticweb.org/ontologies/A"
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/A"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/ontologies/A#A -->
<owl:Class rdf:about="http://www.semanticweb.org/ontologies/A#A">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/ontologies/A#B"/>
</owl:Class>
<!-- http://www.semanticweb.org/ontologies/A#B -->
<owl:Class rdf:about="http://www.semanticweb.org/ontologies/A#B">
<owl:equivalentClass rdf:resource="http://www.semanticweb.org/ontologies/A#C"/>
</owl:Class>
<!-- http://www.semanticweb.org/ontologies/A#C -->
<owl:Class rdf:about="http://www.semanticweb.org/ontologies/A#C"/>
</rdf:RDF>
<!-- Generated by the OWL API (version 3.5.1) http://owlapi.sourceforge.net -->
以下是我的Java代碼 : -
//Some work done to load ontology
ReasonerFactory factory = new ReasonerFactory();
Reasoner reasoner = new Reasoner(reasonerConf, owlOntology);
BlackBoxExplanation explain = new BlackBoxExplanation(owlOntology, factory, reasoner);
HSTExplanationGenerator multiEx = new HSTExplanationGenerator(explain);
InferredSubClassAxiomGenerator gen = new InferredSubClassAxiomGenerator();
Set<OWLSubClassOfAxiom> subClass = gen.createAxioms(dataFactory, reasoner);
SatisfiabilityConverter converter = new SatisfiabilityConverter(dataFactory);
for (OWLSubClassOfAxiom ax : subClass) {
System.out.println("\nAxiom :- " + ax);
System.out.println("Is axiom entailed by reasoner ? :- " + reasoner.isEntailed(ax));
System.out.println("Is axiom contained in ontology ? :- " + owlOntology.containsAxiom(ax));
Set<Set<OWLAxiom>> expl = multiEx.getExplanations(converter.convert(ax));
System.out.println("No. of Explanations :- " + expl.size());
System.out.println("Explanation :- ");
for (Set<OWLAxiom> a : expl) {
System.out.println(a);
}
}
根據我的代碼,這里是輸出 : -
Axiom :- SubClassOf(<http://www.semanticweb.org/ontologies/A#B> owl:Thing)
Is axiom entailed by reasoner ? :- true
Is axiom contained in ontology ? :- false
No. of Explanations :- 1
Explanation :-
[EquivalentClasses(<http://www.semanticweb.org/ontologies/A#B> <http://www.semanticweb.org/ontologies/A#C> )]
Axiom :- SubClassOf(<http://www.semanticweb.org/ontologies/A#C> owl:Thing)
Is axiom entailed by reasoner ? :- true
Is axiom contained in ontology ? :- false
No. of Explanations :- 1
Explanation :-
[EquivalentClasses(<http://www.semanticweb.org/ontologies/A#B> <http://www.semanticweb.org/ontologies/A#C> )]
Axiom :- SubClassOf(<http://www.semanticweb.org/ontologies/A#A> <http://www.semanticweb.org/ontologies/A#B>)
Is axiom entailed by reasoner ? :- true
Is axiom contained in ontology ? :- true
No. of Explanations :- 1
Explanation :-
[SubClassOf(<http://www.semanticweb.org/ontologies/A#A> <http://www.semanticweb.org/ontologies/A#B>)]
Axiom :- SubClassOf(<http://www.semanticweb.org/ontologies/A#A> <http://www.semanticweb.org/ontologies/A#C>)
Is axiom entailed by reasoner ? :- true
Is axiom contained in ontology ? :- false
No. of Explanations :- 1
Explanation :-
[EquivalentClasses(<http://www.semanticweb.org/ontologies/A#B> <http://www.semanticweb.org/ontologies/A#C> ), SubClassOf(<http://www.semanticweb.org/ontologies/A#A> <http://www.semanticweb.org/ontologies/A#B>)]
我有以下問題:
1)此代碼是否足以得出推斷的公理? (就像我可以檢查原始本體中是否有新的公理可用,如果沒有那么它是推斷的公理 - [照顧公理說C SubClassOf owl:Thing
])
2)推理器的isEntailed()
方法有什么用?如果它總是給出true
?
3)推斷公理總有一種解釋。 這是正確的嗎 ? 對於推斷的公理A SubClassOf C
,有1個解釋,但其Set
與protege中顯示的相反(順序)。 所以我需要反向展示它嗎?
保護圖片 : -
1)是的,它已經足夠了 - 本體中所包含和存在的公理通常稱為“斷言”。
2)isEntailed()並不總是返回true。 它適用於你正在使用的公理 - 嘗試詢問owl:Thing是否為子類,如果owl:Nothing。
3)對於所包含的公理至少有一種解釋。 當公理包含在本體中時,這是一個微不足道的解釋 - 所有包含的公理都是必需的。 對於更復雜的情況,可以進行多種解釋。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.