1

与直接使用 OWL API 相比,我对 Protégé 中的子类处理有点困惑。

我建立了一个简单的本体,我在其中逻辑地定义了“男人”或“女人”是什么,即男性或女性。

课程是

Human
Woman
Man
Gender
    Female
    Male

特性:

hasSex (Human -> Gender)

所以一个女人是人类并且有一些女性的性别

我的问题:当我在 Protégé 中显示这个本体时,它会自动将 Man 和 Woman 组织为 Human 的子类,而不使用推理器。但是,当我遍历 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é 是否有一些用于“清除”子类案例的内置规则?我在哪里可以找到它们?

作为参考,示例本体和 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));
    });
}
4

1 回答 1

0

简短的回答是肯定的,Protégé 有一些最小的推理来组织断言的层次结构。

于 2017-05-17T05:33:28.413 回答