简体   繁体   English

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

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

I am currently building/modifying a larger ontology. 我目前正在构建/修改更大的本体。 As I had problems to define restrictions I build a very short example: I have EuropeanCountry as a class and IslandCountry as a class: 由于我在定义限制方面遇到问题,因此我举了一个非常简短的示例:我将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>

As you can see I set a "maxQualifiedCardinality" restriction in Protege. 如您所见,我在Protege中设置了“ maxQualifiedCardinality”限制。 If I create some individuals and (C1, C2 and Germany are EuropeanCountry, Island is IslandCountry) and relate them with the border property: 如果我创建了一些个人,并且(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>

I get an error thrown by Hermit reasoner that it is not allowed to set 3 neighbours to Island. 我收到隐士推理机抛出的错误,不允许将3个邻居设置为Island。 If I now change the line 如果我现在换线

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

to cardinality 1 I don't get any error if I set three neighbours as shown in the example. 基数1如果按示例所示设置三个邻居,则不会出现任何错误。 Can anyone explain this and hopefully provide me a solution how I can write a restriction that one class should have x other classes (in this case how to write that Island should have 2 neighbours and a third one will throw an error by the reasoner)? 谁能解释这个问题,并希望为我提供一个解决方案,让我如何编写一个类应具有x个其他类的限制(在这种情况下,如何写出Island应该有2个邻居,而第三个应由推理机抛出错误)?

Thanks for your help and kind regards, 感谢您的帮助和问候,

tanktoo Tanktoo

Edit: I have now added all individuals to an AllDifferent: 编辑:我现在将所有个人添加到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>

It is now working with the restriction above and the reasoner tells me that I am not allowed to set 3 border countries as maxCardinality is 1. I have now changed my restriction to the following: 现在它正在使用上面的限制,并且推理机告诉我,由于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>

I would now expect that the reasoner detects an error if I set less than 1 or more than 2 neighbours: 我现在希望,如果我设置的邻居少于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>

In this case the reasoner detects an errro because there are 3 neighbours. 在这种情况下,推理者会发现一个错误,因为有3个邻居。 If I now delete all the neighbours so that Island border 0 countries the reasoner doesn't give me an error. 如果现在删除所有邻居,以使岛屿边界为0个国家,则推理机不会给我错误。 Can someone explain me why? 有人可以解释我为什么吗?

Thanks for your help :) 谢谢你的帮助 :)

I get an error thrown by Hermit reasoner that it is not allowed to set 3 neighbours to Island 我收到隐士推理机抛出的错误,不允许将3个邻居设置为Island

If this is what the tool says, then it is a mistake. 如果这就是工具所说的话,那就是一个错误。 Granted, you are giving 3 names of bordering countries. 当然,您将给出3个毗邻国家的名称。 But nothing says that these are names of 3 different countries. 但是没有人说这是3个不同国家的名字。 They could be several names of the same country, like "France", "Republic of France", "République française". 它们可能是同一个国家的多个名称,例如“法国”,“法兰西共和国”,“法国共和国”。

Since the reasoner has no way of knowing whether they are names of the same thing or not, it can't detect an inconsistency in the second case. 由于推理机无法知道它们是否是同一事物的名称,因此在第二种情况下它无法检测到不一致之处。 However, in the first case, having at least a name for something means that there is strictly more than zero thing, so it makes sense that an inconsistency is detected. 但是,在第一种情况下,至少为某事物指定名称意味着严格存在的事物不止零,因此检测到不一致是有意义的。

If you'd like to make sure the reasoner detects when a country has more than 2 neighbours, then you'd have to explicitly say that the countries are different: 如果您想确保推理机能够检测到一个国家有两个以上的邻居,那么您必须明确地说出这些国家是不同的:

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

or: 要么:

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

In Protégé, in the Individual tab, you can specify from what an individual is different. 在Protégé的“个人”选项卡中,您可以指定个人的不同之处。

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

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