【问题标题】:(Un)Inferred Subclass Rules Protégé vs OWL API(Un)Inferred Subclass Rules Protégé vs OWL API
【发布时间】:2017-10-15 08:22:48
【问题描述】:

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

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

类是

Human
Woman
Man
Gender
    Female
    Male

属性:

hasSex (Human -> Gender)

所以女人是 Human and hasGender 一些女性

我的问题:当我在 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));
    });
}

【问题讨论】:

    标签: owl protege owl-api description-logic


    【解决方案1】:

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

    【讨论】:

    • 您好,Ignazio,谢谢您的回答!有什么办法可以查到这些规则?我的意思是除了从 Protégé 代码中提取它们:-D
    • 据我所知,它们是在 protégé 源代码中硬编码的,恐怕。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-05-28
    • 1970-01-01
    • 2014-02-25
    • 1970-01-01
    • 2018-11-19
    • 2020-01-01
    • 2018-10-24
    相关资源
    最近更新 更多