【问题标题】:Assigning a value to a property based on a SWRL rule (Protege 4.3 with Pellet as reasoner)根据 SWRL 规则为属性赋值(Protege 4.3 使用 Pellet 作为推理器)
【发布时间】:2014-02-11 12:38:54
【问题描述】:

我的问题与 SWRL 规则有关,实际上已被其他用户提出(请参阅 Ontology property definition in Protégé-OWL / SWRL)。尽管如此,在按照如何让它工作的说明之后,我还是没有成功。

在我的本体中,我必须处理一些复杂的时间事实(与时间间隔等相关),因此我导入了Time Ontology。在解决实际问题之前,我先考虑一个简单的示例,测试如何根据 SWRL 规则为数据属性分配值。这个简单的例子处理一个类Person。还有一个类 BirthYear(时间本体的 Instant 类的子类)。对象属性 bornInYear,域 Person 和范围 BirthYearPerson 与他/她的出生年份联系起来.我想计算这个人当年的年龄,所以我制定了这个SWRL规则:

人(?p) ∧bornInYear(?p, ?birthYear) ∧ 减法(?age, 2014, ?birthYear) &右箭头;年龄(?p, ?age)

在创建一个 Person 类的个体并断言他/她的 BirthYear 具有值 "1977" 之后,我希望 Pellet 计算出这个人的年龄是 37。这不会发生。知道为什么吗? SWRL 规则是否正确? (为了知道值 37 是否被断言到数据属性 age,我查看了个人 p 的“属性断言”视图。我还确保在推理器偏好中复选框“对象属性断言”被选中。)我的示例本体如下:

Prefix(SWRLexample:=<http://www.semanticweb.org/ontologies/2014/1/SWRLexample#>)
Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)
Prefix(swrlb:=<http://www.w3.org/2003/11/swrlb#>)
Prefix(owl:=<http://www.w3.org/2002/07/owl#>)
Prefix(:=<http://www.semanticweb.org/ontologies/2014/1/untitled-ontology-101#>)
Prefix(time:=<http://www.w3.org/2006/time#>)
Prefix(xml:=<http://www.w3.org/XML/1998/namespace>)
Prefix(rdf:=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>)
Prefix(swrl:=<http://www.w3.org/2003/11/swrl#>)
Prefix(rdfs:=<http://www.w3.org/2000/01/rdf-schema#>)


Ontology(<http://www.semanticweb.org/ontologies/2014/1/SWRLexample>
Import(<http://www.w3.org/2006/time>)

Declaration(Class(SWRLexample:BirthYear))
SubClassOf(SWRLexample:BirthYear time:Instant)
Declaration(Class(SWRLexample:Person))
Declaration(ObjectProperty(SWRLexample:bornInYear))
ObjectPropertyDomain(SWRLexample:bornInYear SWRLexample:Person)
ObjectPropertyRange(SWRLexample:bornInYear SWRLexample:BirthYear)
Declaration(DataProperty(SWRLexample:age))
AnnotationAssertion(rdfs:comment SWRLexample:age "Age of a person in years")
DataPropertyDomain(SWRLexample:age SWRLexample:Person)
DataPropertyRange(SWRLexample:age xsd:int)
Declaration(NamedIndividual(SWRLexample:birthYear1))
ClassAssertion(SWRLexample:BirthYear SWRLexample:birthYear1)
DataPropertyAssertion(time:year SWRLexample:birthYear1 "1977"^^xsd:gYear)
Declaration(NamedIndividual(SWRLexample:p1))
ClassAssertion(SWRLexample:Person SWRLexample:p1)
ObjectPropertyAssertion(SWRLexample:bornInYear SWRLexample:p1 SWRLexample:birthYear1)
DLSafeRule(Body(ClassAtom(SWRLexample:Person Variable(<urn:swrl#p>)) ObjectPropertyAtom(SWRLexample:bornInYear Variable(<urn:swrl#p>) Variable(<urn:swrl#birthYear>)) BuiltInAtom(swrlb:subtract Variable(<urn:swrl#age>) "2014"^^xsd:integer Variable(<urn:swrl#birthYear>)))Head(DataPropertyAtom(SWRLexample:age Variable(<urn:swrl#p>) Variable(<urn:swrl#age>))))
)

【问题讨论】:

  • 实际上,我刚刚注意到,Pellet 会产生以下错误消息:2014 年 2 月 11 日下午 1:43:45 com.clarkparsia.pellet.rules.BindingGeneratorStrategyImp l createGenerator Warnung: IGNORING RULE Rule([ Person(?p),bornInYear(?p,?birthYear),subtract([?age, "2014"^^integer, ?birthYear])] => [age(?p,?age)]): 无法生成身体约束的安全排序。在 280 毫秒内分类的颗粒

标签: owl protege pellet swrl


【解决方案1】:

有一些问题(但我很高兴其他答案是一个有用的起点):

  • age 是一个 data 属性,因此您不仅需要确保“选中“对象属性断言”复选框,还需要确保“数据属性断言”,因为它是您要查找的数据类型断言。

  • BornInYear 是一个 object 属性,因此bornInYear(?p, ?birthYear) 中的?birthYear 必须是个人。但是,swrlb:subtract 的参数必须是数字文字。要使用 swrlb:subtract,您需要在规则中获取年份的整数值并对其执行算术运算。你应该可以毫不费力地做到这一点,尽管我不确定你是否仍然可以使用值"1977"^^xsd:gYear。不过,SWRL 确实定义了一些处理日期和时间的函数(请参阅8.5. Built-Ins for Date, Time and Duration)。不过,并非所有推理者都支持这一点(例如,我认为 Pellet 不支持)。但是,year 属性的值确实 需要是 xsd:gYear

【讨论】:

  • 谢谢Joshua,你当然是对的。它是一个数据属性,我选中了“数据属性断言”复选框。只是混淆了我帖子中的术语。关于内置减法 SWRL 参数的第二点可能是我的问题的解决方案。我现在要调查一下!谢谢
  • @Sabina 我也一直在研究它,我认为您将能够使用日期算术函数(如果您使用支持它们的推理器),但您需要弄清楚如何在 SWRL 规则中构造日期或时间对象;我不认为你只能使用 gYears。
  • @Joshua Pellet 支持一些与 dateTime 相关的 SWRL 内置插件 (clarkparsia.com/pellet/faq/rules)。这就是我求助于时间本体的原因,因为使用简单的 int 值和支持的 SWRL 似乎不够表达。例如。当我需要在我的用例中说明保修时间为 2 年时,从购买物品之日开始。如果有类似将 gYear 转换为 int 的方法,我认为这将有助于解决我当前的问题。
  • @Sabina。 Pellet 支持五种允许您从组件构造或从持续时间、日期、时间和日期时间提取组件的方法。根据您可以提取的组件类型,如果您在其他地方使用过日期或日期时间,则可能可以获得所需的数字。
【解决方案2】:

以下是连续的步骤:

  • 转到元数据选项卡
  • 导入时间本体,前缀为时间。
  • 转到 SWRL 选项卡

写规则如下:

Person(?x) ^ hasDOB(?x, ?dob) ^ temporal:duration(?age, "now", ?dob, temporal:Years) -> hasAge(?x,  ?age)

Person 是一个类 hasDOB,hasAge 是对象属性

【讨论】:

猜你喜欢
  • 2016-06-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-07-27
  • 2013-06-06
  • 2013-02-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多