繁体   English   中英

Protege中的推理机无法使用限制/基数

[英]Reasoner in Protege not working with Restrictions/Cardinalities

我目前正在构建/修改更大的本体。 由于我在定义限制方面遇到问题,因此我举了一个非常简短的示例:我将EuropeanCountry作为一个类,将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和德国是EuropeanCountry,Island是IslandCountry),并将它们与border属性相关联:

<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个邻居设置为Island。 如果我现在换线

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

基数1如果按示例所示设置三个邻居,则不会出现任何错误。 谁能解释这个问题,并希望为我提供一个解决方案,让我如何编写一个类应具有x个其他类的限制(在这种情况下,如何写出Island应该有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个国家,则推理机不会给我错误。 有人可以解释我为什么吗?

谢谢你的帮助 :)

我收到隐士推理机抛出的错误,不允许将3个邻居设置为Island

如果这就是工具所说的话,那就是一个错误。 当然,您将给出3个毗邻国家的名称。 但是没有人说这是3个不同国家的名字。 它们可能是同一个国家的多个名称,例如“法国”,“法兰西共和国”,“法国共和国”。

由于推理机无法知道它们是否是同一事物的名称,因此在第二种情况下它无法检测到不一致之处。 但是,在第一种情况下,至少为某事物指定名称意味着严格存在的事物不止零,因此检测到不一致是有意义的。

如果您想确保推理机能够检测到一个国家有两个以上的邻居,那么您必须明确地说出这些国家是不同的:

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é的“个人”选项卡中,您可以指定个人的不同之处。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM