我遵循通过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推理器,以获得推断的类层次结构及其解释。
下面是我的代码:
//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 :- 0Q1。没有由HermiT推理者产生的解释。(有什么需要得到解释的吗?)
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分别显示推断的公理及其解释。那怎么弄到他们呢?(我增加了一些屏幕截图,以供参考)
我的本体:

对包含的解释:

发布于 2016-07-22 20:44:00
您在解释生成器上使用了错误的方法:我的意思是,您调用
Set<Set<OWLAxiom>> expl = multExplanator.getExplanations(ax.getSuperClass());但是,如果您只提供一个类resp,您为什么认为这给出了对公理的解释。课堂表达?在查看Javadoc时,它说您调用的方法
“返回给定的不可满足类的所有解释。”
这只是公理SubClassOf(CE, owl:Nothing)的一个方便的方法,即类CE是不可满足的。在OWL中,您可以通过公理进行声明,而这是唯一可以真正重新定位的东西。等一下,就这样被牵扯进来了。简单地说,您必须使用子类公理并将其转换为一个类表达式,然后测试它的不可满足性:
A SubClassOf B => A and not B
对于任何OWL公理,都有一个转换器类为您执行此操作:
com.clarkparsia.owlapi.explanation.SatisfiabilityConverter::convert(OWLAxiom axiom)
https://stackoverflow.com/questions/38524465
复制相似问题