【发布时间】:2014-02-11 12:38:54
【问题描述】:
我的问题与 SWRL 规则有关,实际上已被其他用户提出(请参阅 Ontology property definition in Protégé-OWL / SWRL)。尽管如此,在按照如何让它工作的说明之后,我还是没有成功。
在我的本体中,我必须处理一些复杂的时间事实(与时间间隔等相关),因此我导入了Time Ontology。在解决实际问题之前,我先考虑一个简单的示例,测试如何根据 SWRL 规则为数据属性分配值。这个简单的例子处理一个类Person。还有一个类 BirthYear(时间本体的 Instant 类的子类)。对象属性 bornInYear,域 Person 和范围 BirthYear 将 Person 与他/她的出生年份联系起来.我想计算这个人当年的年龄,所以我制定了这个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 毫秒内分类的颗粒