Protege中的推理者不使用限制/基数

时间:2016-11-22 16:13:07

标签: owl protege cardinality reasoning

我目前正在构建/修改更大的本体。由于我有定义限制的问题,我建立了一个非常简短的例子: 我将EuropeCountry作为班级,将IslandCountry作为班级:     

<owl:Class rdf:about="http://www.semanticweb.org/tanktoo/ontologies/2016/10/untitled-ontology-81#EuropeanCountry">
    <rdfs:subClassOf rdf:resource="http://www.semanticweb.org/tanktoo/ontologies/2016/10/untitled-ontology-81#Country"/>
</owl:Class>



<!-- http://www.semanticweb.org/tanktoo/ontologies/2016/10/untitled-ontology-81#IslandCountry -->

<owl:Class rdf:about="http://www.semanticweb.org/tanktoo/ontologies/2016/10/untitled-ontology-81#IslandCountry">
    <rdfs:subClassOf rdf:resource="http://www.semanticweb.org/tanktoo/ontologies/2016/10/untitled-ontology-81#Country"/>
    <rdfs:subClassOf>
        <owl:Restriction>
            <owl:onProperty rdf:resource="http://www.semanticweb.org/tanktoo/ontologies/2016/10/untitled-ontology-81#borders"/>
            <owl:maxQualifiedCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">0</owl:maxQualifiedCardinality>
            <owl:onClass rdf:resource="http://www.semanticweb.org/tanktoo/ontologies/2016/10/untitled-ontology-81#EuropeanCountry"/>
        </owl:Restriction>
    </rdfs:subClassOf>
</owl:Class>

正如您所看到的,我在Protege中设置了“maxQualifiedCardinality”限制。如果我创造了一些人(C1,C2和德国是欧洲国家,岛屿是IslandCountry)并将他们与边境财产联系起来:

<owl:NamedIndividual rdf:about="http://www.semanticweb.org/tanktoo/ontologies/2016/10/untitled-ontology-81#Island">
    <rdf:type rdf:resource="http://www.semanticweb.org/tanktoo/ontologies/2016/10/untitled-ontology-81#IslandCountry"/>
    <borders rdf:resource="http://www.semanticweb.org/tanktoo/ontologies/2016/10/untitled-ontology-81#C1"/>
    <borders rdf:resource="http://www.semanticweb.org/tanktoo/ontologies/2016/10/untitled-ontology-81#C2"/>
    <borders rdf:resource="http://www.semanticweb.org/tanktoo/ontologies/2016/10/untitled-ontology-81#Germany"/>
</owl:NamedIndividual>

我得到Hermit推理者抛出的一个错误,即不允许将3个邻居设置为Island。如果我现在更改行

<owl:maxQualifiedCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">1</owl:maxQualifiedCardinality>

to cardinality 1如果我设置了三个邻居,我没有收到任何错误,如示例所示。 任何人都可以解释这一点,并希望为我提供一个解决方案,我可以写一个限制,一个类应该有x个其他类(在这种情况下如何编写该岛应该有2个邻居,第三个将由推理者抛出错误)?

感谢您的帮助和亲切的问候,

tanktoo

编辑: 我现在已将所有人添加到AllDifferent:

<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/tanktoo/ontologies/2016/10/untitled-ontology-81#C1"/>
        <rdf:Description rdf:about="http://www.semanticweb.org/tanktoo/ontologies/2016/10/untitled-ontology-81#C2"/>
        <rdf:Description rdf:about="http://www.semanticweb.org/tanktoo/ontologies/2016/10/untitled-ontology-81#Germany"/>
    </owl:distinctMembers>
</rdf:Description>

现在正在使用上述限制,推理者告诉我,由于maxCardinality为1,我不允许设置3个边境国家/地区。 我现在已将限制改为以下内容:

<owl:Class rdf:about="http://www.semanticweb.org/tanktoo/ontologies/2016/10/untitled-ontology-81#IslandCountry">
    <rdfs:subClassOf rdf:resource="http://www.semanticweb.org/tanktoo/ontologies/2016/10/untitled-ontology-81#Country"/>
    <rdfs:subClassOf>
        <owl:Restriction>
            <owl:onProperty rdf:resource="http://www.semanticweb.org/tanktoo/ontologies/2016/10/untitled-ontology-81#borders"/>
            <owl:minQualifiedCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">1</owl:minQualifiedCardinality>
            <owl:onClass rdf:resource="http://www.semanticweb.org/tanktoo/ontologies/2016/10/untitled-ontology-81#EuropeanCountry"/>
        </owl:Restriction>
    </rdfs:subClassOf>
    <rdfs:subClassOf>
        <owl:Restriction>
            <owl:onProperty rdf:resource="http://www.semanticweb.org/tanktoo/ontologies/2016/10/untitled-ontology-81#borders"/>
            <owl:maxQualifiedCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">2</owl:maxQualifiedCardinality>
            <owl:onClass rdf:resource="http://www.semanticweb.org/tanktoo/ontologies/2016/10/untitled-ontology-81#EuropeanCountry"/>
        </owl:Restriction>
    </rdfs:subClassOf>
</owl:Class>

如果设置少于1个或多于2个邻居,我现在希望推理器检测到错误:

<owl:NamedIndividual rdf:about="http://www.semanticweb.org/tanktoo
/ontologies/2016/10/untitled-ontology-81#Island">
        <rdf:type rdf:resource="http://www.semanticweb.org/tanktoo/ontologies/2016/10/untitled-ontology-81#IslandCountry"/>
        <borders rdf:resource="http://www.semanticweb.org/tanktoo/ontologies/2016/10/untitled-ontology-81#C1"/>
        <borders rdf:resource="http://www.semanticweb.org/tanktoo/ontologies/2016/10/untitled-ontology-81#C2"/>
        <borders rdf:resource="http://www.semanticweb.org/tanktoo/ontologies/2016/10/untitled-ontology-81#Germany"/>
    </owl:NamedIndividual>

在这种情况下,推理器检测到错误,因为有3个邻居。如果我现在删除所有邻居,以便岛边界0国家,推理者不会给我一个错误。有人能解释我为什么吗?

感谢您的帮助:)

1 个答案:

答案 0 :(得分:4)

  

我得到Hermit推理者抛出的一个错误,即不允许将3个邻居设置为Island

如果这是工具所说的,那就是错误。当然,你给出了3个接壤国家的名字。但没有说这些是3个不同国家的名字。他们可能是同一个国家的几个名字,如“法国”,“法兰西共和国”,“法国共和国”。

由于推理者无法知道它们是否是相同的名称,因此在第二种情况下无法检测到不一致。但是,在第一种情况下,至少拥有某个名称意味着严格地超过零,所以检测到不一致是有道理的。

如果您想确定推理者检测到某个国家/地区的邻居数超过2个,那么您必须明确说明这些国家/地区是不同的:

ex:C1  owl:differentFrom  ex:C2, ex:Germany .
ex:C2  owl:differentFrom  ex:Germany .

或:

[]  a  owl:AllDifferent;
    owl:members  ( ex:C1 ex:C2 ex:Germany ) .

在Protégé的“个人”选项卡中,您可以指定个人的不同之处。

相关问题