swrl规则来推断dataProperty值 [英] swrl rules to infer dataProperty values

查看:130
本文介绍了swrl规则来推断dataProperty值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to test a simple SWRL rule. There are three Classes in my ontology: LivingPlace which has two sub-classes RuralArea and City. LivingPlace is the domain of the dataProperty hasHospital which has the range boolean.

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

When I test the following rule with Pellet reasoner, the individual I created as a member of LivingPlace is also inferred as a member of RuralArea.

LivingPlace(?lp),hasHospital(?lp,false)→ RuralArea(?lp)

LivingPlace(?lp), hasHospital(?lp, false) → RuralArea(?lp)

但是,我真正想做的是与此相反的推理.

However, what I really want to do is the reverse of this reasoning.

RuralArea(?lp)→ hasHospital(?lp,false)

RuralArea(?lp) → hasHospital(?lp, false)

每当我创建RuralRrea类型的个人时,我都希望Pellet推断hasHospital为false.我该怎么办?

Whenever I create an individual of type RuralArea, I want Pellet to infer a hasHospital of false. How can I do this?

推荐答案

以下是您所描述的类的最小本体,即LivingPlace类具有两个直接子类,即City和RuralArea.有一个个人,RuralArea1,类型为RuralArea,并且本体包含SWRL规则

Here's a minimal ontology with classes as you've described, i.e., the class LivingPlace has two direct subclasses, City and RuralArea. There is one individual, ruralArea1, which is of type RuralArea, and the ontology contains the SWRL rule

RuralArea(?x)→ hasHospital(?x,false)

RuralArea(?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中显示有关数据类型属性的推论(如

When I load this ontology in Protégé 4.x and use Pellet as the reasoner, and also ensure that inferences about datatype properties are displyed in the UI (as discussed in this message on the Protégé OWL mailing list), the inference that

ruralArea1 hasHospital false

显示

,如以下屏幕截图所示.

is displayed, as shown in the following screenshot.

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

Another way to see that Pellet can draw this inference is to ask using SPARQL. For instance, using the SPARQL query saved in query.sparql

prefix : <http://example.org/places#>

select ?s ?o where { 
  ?s :hasHospital ?o 
}

pellet命令行工具,我们得到以下结果:

and the pellet command line tool, we obtain these results:

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

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

It is worth pointing out that you don't actually need SWRL to do this particular inference. You can simply say that

RuralArea subClassOf(医院值为false)

RuralArea subClassOf (hasHospital value false)

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

and get the same results. In Protégé, that would look like the following screenshot. This has the advantage that it will give you the same results if you're using an OWL reasoner that doesn't have SWRL support.

这篇关于swrl规则来推断dataProperty值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆