【问题标题】:swrl rules to infer dataProperty values用于推断 dataProperty 值的 swrl 规则
【发布时间】:2013-02-21 04:43:33
【问题描述】:

我正在尝试测试一个简单的 SWRL 规则。我的本体中有三个类:LivingPlace,它有两个子类 RuralArea 和 City。 LivingPlace 是 dataProperty hasHospital 的域,其范围为布尔值。

当我使用 Pellet 推理器测试以下规则时,我创建为 LivingPlace 成员的个人也被推断为 RuralArea 成员。

LivingPlace(?lp), hasHospital(?lp, false) → 农村地区(?lp)

然而,我真正想做的是与这个推理相反。

农村地区(?lp) → hasHospital(?lp, false)

每当我创建一个 RuralArea 类型的个体时,我都希望 Pellet 推断出一个 false 的 hasHospital。我该怎么做?

【问题讨论】:

    标签: rules owl pellet swrl


    【解决方案1】:

    这是一个包含您所描述的类的最小本体,即 LivingPlace 类有两个直接子类,City 和 RuralArea。有一个个体,ruralArea1,类型为RuralArea,本体包含SWRL规则

    农村地区(?x) → hasHospital(?x,false)

    <rdf:RDF
        xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
        xmlns="http://example.org/places#"
        xmlns:owl="http://www.w3.org/2002/07/owl#"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
        xmlns:swrl="http://www.w3.org/2003/11/swrl#"
        xmlns:swrlb="http://www.w3.org/2003/11/swrlb#"
        xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
      <owl:Ontology rdf:about="http://example.org/places"/>
      <owl:Class rdf:about="http://example.org/places#LivingPlace"/>
      <owl:Class rdf:about="http://example.org/places#City">
        <rdfs:subClassOf rdf:resource="http://example.org/places#LivingPlace"/>
      </owl:Class>
      <owl:Class rdf:about="http://example.org/places#RuralArea">
        <rdfs:subClassOf rdf:resource="http://example.org/places#LivingPlace"/>
      </owl:Class>
      <owl:DatatypeProperty rdf:about="http://example.org/places#hasHospital">
        <rdfs:domain rdf:resource="http://example.org/places#LivingPlace"/>
        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#boolean"/>
      </owl:DatatypeProperty>
      <swrl:Imp>
        <swrl:body>
          <swrl:AtomList>
            <rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
            <rdf:first>
              <swrl:ClassAtom>
                <swrl:classPredicate rdf:resource="http://example.org/places#RuralArea"/>
                <swrl:argument1>
                  <swrl:Variable rdf:about="urn:swrl#x"/>
                </swrl:argument1>
              </swrl:ClassAtom>
            </rdf:first>
          </swrl:AtomList>
        </swrl:body>
        <swrl:head>
          <swrl:AtomList>
            <rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
            <rdf:first>
              <swrl:DatavaluedPropertyAtom>
                <swrl:argument2 rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean"
                >false</swrl:argument2>
                <swrl:propertyPredicate rdf:resource="http://example.org/places#hasHospital"/>
                <swrl:argument1 rdf:resource="urn:swrl#x"/>
              </swrl:DatavaluedPropertyAtom>
            </rdf:first>
          </swrl:AtomList>
        </swrl:head>
      </swrl:Imp>
      <owl:NamedIndividual rdf:about="http://example.org/places#ruralArea1">
        <rdf:type rdf:resource="http://example.org/places#RuralArea"/>
      </owl:NamedIndividual>
    </rdf:RDF>
    

    当我在 Protégé 4.x 中加载此本体并使用 Pellet 作为推理器,并确保在 UI 中显示有关数据类型属性的推论(如 this message on the Protégé OWL mailing list 中所述)时,

    ruralArea1 hasHospital false
    

    显示,如下图所示。

    查看 Pellet 可以得出此推论的另一种方法是使用 SPARQL 进行询问。例如,使用保存在 query.sparql 中的 SPARQL 查询

    prefix : <http://example.org/places#>
    
    select ?s ?o where { 
      ?s :hasHospital ?o 
    }
    

    pellet命令行工具,我们得到这些结果:

    $ pellet query -q query.sparql ./places.owl 
    Query Results (1 answers): 
    s          | o                                              
    ============================================================
    ruralArea1 | false^^http://www.w3.org/2001/XMLSchema#boolean
    

    值得指出的是,您实际上并不需要 SWRL 来执行此特定推理。你可以简单地说

    RuralArea subClassOf (hasHospital value false)

    并获得相同的结果。在 Protégé 中,这将类似于以下屏幕截图。这样做的好处是,如果您使用的是不支持 SWRL 的 OWL 推理器,它将为您提供相同的结果。

    【讨论】:

    • 在首选项中启用数据类型断言是我的关键概念。谢谢
    猜你喜欢
    • 2015-11-23
    • 2013-06-06
    • 2021-07-27
    • 1970-01-01
    • 2011-09-25
    • 2015-05-24
    • 2019-01-28
    • 2021-11-12
    • 1970-01-01
    相关资源
    最近更新 更多