(Un)Inferred Subclass Rules Protected vs OWL API
(Un)Inferred Subclass Rules Protégé vs OWL API
与直接使用 OWL API 相比,我对 Protégé 中的子类处理有点困惑。
我建立了一个简单的 ontology,我从逻辑上定义了 "Man" 或 "Woman" 是什么,即男性或女性人类。
类是
Human
Woman
Man
Gender
Female
Male
属性:
hasSex (Human -> Gender)
所以女人是
人类和 hasGender 一些女性
我的问题:当我在 Protégé 中显示此 ontology 时,它会自动将男人和女人组织为人类的子类,而无需使用推理器。
但是,当我遍历 OWL API 中的所有 类 并打印它们的子 类 时,只找到断言的子 类:
Subclasses of <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Female>
Subclasses of <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Woman>
Subclasses of <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Male>
Subclasses of <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Human>
Subclasses of <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Gender>
<http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Female>
<http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Male>
Subclasses of <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Man>
我需要使用推理机来获得预期的结果,Protégé 在不使用推理机的情况下显示:
Subclasses of <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Female>
Node( owl:Nothing )
Subclasses of <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Woman>
Node( owl:Nothing )
Subclasses of <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Male>
Node( owl:Nothing )
Subclasses of <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Human>
Node( <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Man> )
Node( <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Woman> )
Subclasses of <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Gender>
Node( <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Female> )
Node( <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Male> )
Subclasses of <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Man>
Node( owl:Nothing )
我在这里做错了什么? Protégé 是否有针对 "clear" 子 类 案例的一些内置规则?我在哪里可以找到它们?
作为参考,示例 ontology 和 OWL API 代码如下:
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Object Properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#hasAge -->
<owl:ObjectProperty rdf:about="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#hasAge">
<rdfs:domain rdf:resource="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Human"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#hasSex -->
<owl:ObjectProperty rdf:about="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#hasSex">
<rdfs:domain rdf:resource="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Human"/>
<rdfs:range rdf:resource="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Gender"/>
</owl:ObjectProperty>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Female -->
<owl:Class rdf:about="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Female">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Gender"/>
</owl:Class>
<!-- http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Gender -->
<owl:Class rdf:about="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Gender"/>
<!-- http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Human -->
<owl:Class rdf:about="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Human"/>
<!-- http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Male -->
<owl:Class rdf:about="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Male">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Gender"/>
</owl:Class>
<!-- http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Man -->
<owl:Class rdf:about="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Man">
<owl:equivalentClass>
<owl:Class>
<owl:intersectionOf rdf:parseType="Collection">
<rdf:Description rdf:about="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Human"/>
<owl:Restriction>
<owl:onProperty rdf:resource="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#hasSex"/>
<owl:someValuesFrom rdf:resource="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Male"/>
</owl:Restriction>
</owl:intersectionOf>
</owl:Class>
</owl:equivalentClass>
</owl:Class>
<!-- http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Woman -->
<owl:Class rdf:about="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Woman">
<owl:equivalentClass>
<owl:Class>
<owl:intersectionOf rdf:parseType="Collection">
<rdf:Description rdf:about="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Human"/>
<owl:Restriction>
<owl:onProperty rdf:resource="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#hasSex"/>
<owl:someValuesFrom rdf:resource="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Female"/>
</owl:Restriction>
</owl:intersectionOf>
</owl:Class>
</owl:equivalentClass>
</owl:Class>
public static void main(String[] args) throws OWLOntologyCreationException {
OWLOntologyManager m = OWLManager.createOWLOntologyManager();
OWLOntology o = m.loadOntologyFromOntologyDocument(new File("testonto/Untitled.owl"));
OWLReasonerFactory reasonerFactory = new JFactFactory();
OWLReasoner reasoner = reasonerFactory.createReasoner(o);
o.classesInSignature().forEach(c -> {
System.out.println("Subclasses of " + c);
reasoner.getSubClasses(c, true).forEach(sc -> System.out.println(" " + sc));
// EntitySearcher.getSubClasses(c, o).forEach(sc -> System.out.println(" " + sc));
});
}
简短的回答是肯定的,Protégé 有一些最小的推理来组织断言的层次结构。
与直接使用 OWL API 相比,我对 Protégé 中的子类处理有点困惑。
我建立了一个简单的 ontology,我从逻辑上定义了 "Man" 或 "Woman" 是什么,即男性或女性人类。
类是
Human
Woman
Man
Gender
Female
Male
属性:
hasSex (Human -> Gender)
所以女人是 人类和 hasGender 一些女性
我的问题:当我在 Protégé 中显示此 ontology 时,它会自动将男人和女人组织为人类的子类,而无需使用推理器。 但是,当我遍历 OWL API 中的所有 类 并打印它们的子 类 时,只找到断言的子 类:
Subclasses of <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Female>
Subclasses of <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Woman>
Subclasses of <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Male>
Subclasses of <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Human>
Subclasses of <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Gender>
<http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Female>
<http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Male>
Subclasses of <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Man>
我需要使用推理机来获得预期的结果,Protégé 在不使用推理机的情况下显示:
Subclasses of <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Female>
Node( owl:Nothing )
Subclasses of <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Woman>
Node( owl:Nothing )
Subclasses of <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Male>
Node( owl:Nothing )
Subclasses of <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Human>
Node( <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Man> )
Node( <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Woman> )
Subclasses of <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Gender>
Node( <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Female> )
Node( <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Male> )
Subclasses of <http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Man>
Node( owl:Nothing )
我在这里做错了什么? Protégé 是否有针对 "clear" 子 类 案例的一些内置规则?我在哪里可以找到它们?
作为参考,示例 ontology 和 OWL API 代码如下:
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Object Properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#hasAge -->
<owl:ObjectProperty rdf:about="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#hasAge">
<rdfs:domain rdf:resource="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Human"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#hasSex -->
<owl:ObjectProperty rdf:about="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#hasSex">
<rdfs:domain rdf:resource="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Human"/>
<rdfs:range rdf:resource="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Gender"/>
</owl:ObjectProperty>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Female -->
<owl:Class rdf:about="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Female">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Gender"/>
</owl:Class>
<!-- http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Gender -->
<owl:Class rdf:about="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Gender"/>
<!-- http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Human -->
<owl:Class rdf:about="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Human"/>
<!-- http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Male -->
<owl:Class rdf:about="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Male">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Gender"/>
</owl:Class>
<!-- http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Man -->
<owl:Class rdf:about="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Man">
<owl:equivalentClass>
<owl:Class>
<owl:intersectionOf rdf:parseType="Collection">
<rdf:Description rdf:about="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Human"/>
<owl:Restriction>
<owl:onProperty rdf:resource="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#hasSex"/>
<owl:someValuesFrom rdf:resource="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Male"/>
</owl:Restriction>
</owl:intersectionOf>
</owl:Class>
</owl:equivalentClass>
</owl:Class>
<!-- http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Woman -->
<owl:Class rdf:about="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Woman">
<owl:equivalentClass>
<owl:Class>
<owl:intersectionOf rdf:parseType="Collection">
<rdf:Description rdf:about="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Human"/>
<owl:Restriction>
<owl:onProperty rdf:resource="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#hasSex"/>
<owl:someValuesFrom rdf:resource="http://www.semanticweb.org/user/ontologies/2017/4/untitled-ontology-222#Female"/>
</owl:Restriction>
</owl:intersectionOf>
</owl:Class>
</owl:equivalentClass>
</owl:Class>
public static void main(String[] args) throws OWLOntologyCreationException {
OWLOntologyManager m = OWLManager.createOWLOntologyManager();
OWLOntology o = m.loadOntologyFromOntologyDocument(new File("testonto/Untitled.owl"));
OWLReasonerFactory reasonerFactory = new JFactFactory();
OWLReasoner reasoner = reasonerFactory.createReasoner(o);
o.classesInSignature().forEach(c -> {
System.out.println("Subclasses of " + c);
reasoner.getSubClasses(c, true).forEach(sc -> System.out.println(" " + sc));
// EntitySearcher.getSubClasses(c, o).forEach(sc -> System.out.println(" " + sc));
});
}
简短的回答是肯定的,Protégé 有一些最小的推理来组织断言的层次结构。