Protege 中具有不相交 类 的对象属性

Object Properties with disjoint classes in Protege

我想建立一个 ontology 模型,我可以在其中表示实体的缺失。 例如,我想要 Rain 和 No_Rain,我将其定义为不相交的 类。 在此之后我有对象 属性 has_rain。 我想以某种方式能够推断出同一个人不可能同时拥有 has_rain(Rain) 和 has_rain(No_Rain) 我搜索了很多,但找不到我的问题的答案。也许我在某个地方错过了它。抱歉,如果我没有很好地解释一切,这是我的第一个问题。我希望你明白一切,并提前致谢! 编辑:

<!-- 
///////////////////////////////////////////////////////////////////////////////////////
//
// Object Properties
//
///////////////////////////////////////////////////////////////////////////////////////
 -->




<!-- http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#has_rain -->

<owl:ObjectProperty rdf:about="http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#has_rain">
    <rdfs:subPropertyOf rdf:resource="http://www.w3.org/2002/07/owl#topObjectProperty"/>
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#FunctionalProperty"/>
</owl:ObjectProperty>



<!-- 
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
 -->




<!-- http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#No_Rain -->

<owl:Class rdf:about="http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#No_Rain"/>



<!-- http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#Rain -->

<owl:Class rdf:about="http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#Rain"/>



<!-- http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#Scene -->

<owl:Class rdf:about="http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#Scene"/>



<!-- 
///////////////////////////////////////////////////////////////////////////////////////
//
// Individuals
//
///////////////////////////////////////////////////////////////////////////////////////
 -->




<!-- http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#no_rain -->

<owl:NamedIndividual rdf:about="http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#no_rain"/>



<!-- http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#rain -->

<owl:NamedIndividual rdf:about="http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#rain"/>



<!-- http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#scene -->

<owl:NamedIndividual rdf:about="http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#scene">
    <has_rain rdf:resource="http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#rain"/>
</owl:NamedIndividual>



<!-- 
///////////////////////////////////////////////////////////////////////////////////////
//
// General axioms
//
///////////////////////////////////////////////////////////////////////////////////////
 -->

<rdf:Description>
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#AllDifferent"/>
    <owl:distinctMembers rdf:parseType="Collection">
        <rdf:Description rdf:about="http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#no_rain"/>
        <rdf:Description rdf:about="http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#rain"/>
    </owl:distinctMembers>
</rdf:Description>
</rdf:RDF>

我也开始使用 owlready,但我还是新手,但如果我必须在代码中对此建模,那就是:

with ontology:
class Rain(Thing):
    pass

class No_Rain(Thing):
    pass

class Scene(Thing):
    pass

class has_rain(ObjectProperty):
    domain = [Scene]
    range = [Rain or No_Rain]

rain = Rain("rain")
no_rain = No_Rain("no_rain")
AllDisjoint(Rain, No_Rain)

我希望这能让它更清楚。

class hierarchy

object properties

individuals

scene individual

编辑:这样做实际上是错误的。

好吧实际上我设法解决了我的问题 :D 如果您将对象 属性 定义为功能对象,然后尝试将一个人与雨和 no_rain 联系起来,那么推理机会告诉您这是不一致的,这正是我所需要的。 如果有人说,如果这是建模它的正确方法,我仍然会很高兴。 enter image description here

您似乎想要定义可以有不同天气的场景。一个场景最好不能既有雪又有干。

因为这是一个场景,所以我会定义不同类型的SceneWeather,即DrySceneSnowySceneRainyScene,它们是互不相交的-它不能同时下雪和下雨。然后我将对象属性 hasRain 定义为 RainyScene 作为域,同样地 hasSnowisDry.

我已经介绍了 SceneWeather 作为家长 class,假设您可能想要捕获各种与场景相关的信息。在下面的示例中,我将 SceneTimeOfDayMorning 作为子 class 并将 isMorning 作为对象 属性 并将 Morning 作为域。

基于以上内容,您可以通过断言 snowyMorningScene 我们有 hasSnowisMorning 来定义 snowyMorningScene。使用推理器,它将推断 snowyMorningScene 属于 SnowySceneMorning 类型。如果现在声明 snowyMorningScene isDry,将导致不一致。

下面是完成此操作的 ontology。

<rdf:RDF xmlns="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#"
     xml:base="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291"
     xmlns:owl="http://www.w3.org/2002/07/owl#"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:xml="http://www.w3.org/XML/1998/namespace"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
     xmlns:untitled-ontology-291="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#">
    <owl:Ontology rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291"/>
    


    <!-- 
    ///////////////////////////////////////////////////////////////////////////////////////
    //
    // Object Properties
    //
    ///////////////////////////////////////////////////////////////////////////////////////
     -->

    


    <!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#isDry -->

    <owl:ObjectProperty rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#isDry">
        <rdfs:subPropertyOf rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#sceneWeather"/>
        <rdfs:domain rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#DryScene"/>
    </owl:ObjectProperty>
    


    <!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#isMorning -->

    <owl:ObjectProperty rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#isMorning">
        <rdfs:subPropertyOf rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#sceneTimeOfDay"/>
        <rdfs:domain rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#Morning"/>
    </owl:ObjectProperty>
    


    <!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#isRainy -->

    <owl:ObjectProperty rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#isRainy">
        <rdfs:subPropertyOf rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#sceneWeather"/>
        <rdfs:domain rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#RainyScene"/>
    </owl:ObjectProperty>
    


    <!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#isSnowy -->

    <owl:ObjectProperty rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#isSnowy">
        <rdfs:subPropertyOf rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#sceneWeather"/>
        <rdfs:domain rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#SnowyScene"/>
    </owl:ObjectProperty>
    


    <!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#sceneTimeOfDay -->

    <owl:ObjectProperty rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#sceneTimeOfDay"/>
    


    <!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#sceneWeather -->

    <owl:ObjectProperty rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#sceneWeather"/>
    


    <!-- 
    ///////////////////////////////////////////////////////////////////////////////////////
    //
    // Classes
    //
    ///////////////////////////////////////////////////////////////////////////////////////
     -->

    


    <!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#DryScene -->

    <owl:Class rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#DryScene">
        <rdfs:subClassOf rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#SceneWeather"/>
    </owl:Class>
    


    <!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#MidDay -->

    <owl:Class rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#MidDay">
        <rdfs:subClassOf rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#SceneTimeOfDay"/>
        <owl:disjointWith rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#Morning"/>
    </owl:Class>
    


    <!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#Morning -->

    <owl:Class rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#Morning">
        <rdfs:subClassOf rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#SceneTimeOfDay"/>
    </owl:Class>
    


    <!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#RainyScene -->

    <owl:Class rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#RainyScene">
        <rdfs:subClassOf rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#SceneWeather"/>
    </owl:Class>
    


    <!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#Scene -->

    <owl:Class rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#Scene"/>
    


    <!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#SceneTimeOfDay -->

    <owl:Class rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#SceneTimeOfDay">
        <rdfs:subClassOf rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#Scene"/>
    </owl:Class>
    


    <!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#SceneWeather -->

    <owl:Class rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#SceneWeather">
        <rdfs:subClassOf rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#Scene"/>
    </owl:Class>
    


    <!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#SnowyScene -->

    <owl:Class rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#SnowyScene">
        <rdfs:subClassOf rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#SceneWeather"/>
    </owl:Class>
    


    <!-- 
    ///////////////////////////////////////////////////////////////////////////////////////
    //
    // Individuals
    //
    ///////////////////////////////////////////////////////////////////////////////////////
     -->

    


    <!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#dry -->

    <owl:NamedIndividual rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#dry"/>
    


    <!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#morning -->

    <owl:NamedIndividual rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#morning"/>
    


    <!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#snow -->

    <owl:NamedIndividual rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#snow"/>
    


    <!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#snowyMorningScene -->

    <owl:NamedIndividual rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#snowyMorningScene">
        <isDry rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#dry"/>
        <isMorning rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#morning"/>
        <isSnowy rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#snow"/>
    </owl:NamedIndividual>
    


    <!-- 
    ///////////////////////////////////////////////////////////////////////////////////////
    //
    // General axioms
    //
    ///////////////////////////////////////////////////////////////////////////////////////
     -->

    <rdf:Description>
        <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#AllDisjointClasses"/>
        <owl:members rdf:parseType="Collection">
            <rdf:Description rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#DryScene"/>
            <rdf:Description rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#RainyScene"/>
            <rdf:Description rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#SnowyScene"/>
        </owl:members>
    </rdf:Description>
</rdf:RDF>



<!-- Generated by the OWL API (version 4.5.9.2019-02-01T07:24:44Z) https://github.com/owlcs/owlapi -->