【问题标题】:Reasoner in Protege not working with Restrictions/CardinalitiesProtege 中的 Reasoner 不使用限制/基数
【发布时间】:2016-11-22 16:13:06
【问题描述】:

我目前正在构建/修改一个更大的本体。由于我在定义限制时遇到问题,我构建了一个非常简短的示例: 我有 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)并将它们与边界属性相关联:

<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 reasoner 抛出的错误,即不允许为 Island 设置 3 个邻居。如果我现在换行

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

到基数 1 如果我设置三个邻居,如示例所示,我不会收到任何错误。 任何人都可以解释这一点,并希望为我提供一个解决方案,我可以如何编写一个类应该有 x 个其他类的限制(在这种情况下,如何编写 Island 应该有 2 个邻居,而第三个邻居会被推理器抛出错误)?

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

坦克也

编辑: 我现在已将所有个人添加到 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>

它现在正在使用上述限制,推理器告诉我,我不允许设置 3 个边境国家,因为 maxCardinality 为 1。 我现在已将我的限制更改为以下内容:

<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 个国家/地区,推理器不会给我一个错误。谁能解释一下为什么?

感谢您的帮助:)

【问题讨论】:

  • 很高兴看到完整的异常。我认为 HermiT 不会/可以对您提供的本体抛出任何错误。
  • 如果我将 maxQualifiedCardinality 设置为 0,我会收到一条消息(我不是指 Hermit 不工作的错误消息),我不允许这样做。

标签: owl protege cardinality reasoning


【解决方案1】:

我收到 Hermit reasoner 抛出的错误,即不允许为 Island 设置 3 个邻居

如果这是工具所说的,那么这是一个错误。当然,您提供了 3 个毗邻国家/地区的名称。但没有什么说这些是 3 个不同国家的名称。它们可以是同一个国家的多个名称,例如“France”、“Republic of France”、“République française”。

由于推理器无法知道它们是否是同一事物的名称,因此在第二种情况下无法检测到不一致。但是,在第一种情况下,至少有一个名称意味着严格地大于零的东西,因此检测到不一致是有道理的。

如果您想确保推理器检测到一个国家/地区何时有超过 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é 的“个人”选项卡中,您可以指定个人的不同之处。

【讨论】:

  • 您好,感谢您的回答。我希望所有具有不同名称的东西都是不同的(这需要我明确地说一个新个体不同于现有的一切,这可能需要大量工作)。我现在得到了使用 AllDifferent 和 maxCardinality 的示例,但是如果我设置了一个额外的 minCardinality 1 并将 maxCardinality 更改为 2,那么推理器仅在我设置超过 3 个边境国家时才会检测到这种情况。如果我没有设置边境国家,它什么也检测不到,为什么?你有想法吗?谢谢!
  • OWL 中没有唯一名称假设,这就是为什么不同的名称并不意味着不同的实体。
  • 好的,谢谢这个关键字。所以我必须将我所有的实例添加到 AllDifferent。
  • tanktoo,说一个国家至少有一个邻国,而不是命名一个邻国,这并没有矛盾。我可以说所有人都有母亲(Person SubClassOf hasParent min 1 Person),我是一个人(me type Person)。你会说这是不一致的,因为我没有命名我的母亲吗?如果您的系统必须能够识别邻国,那么您必须依赖一致性以外的其他东西。
猜你喜欢
  • 1970-01-01
  • 2014-09-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-10-16
  • 1970-01-01
  • 2015-07-27
相关资源
最近更新 更多