简体   繁体   English

Protege中的SWRL语法

[英]SWRL syntax in Protege

I am using Protege5.0, and i want to implement SWRL rule ie 我正在使用Protege5.0,我想实现SWRL规则,即

User(?u), isInActivity(?u, ?cm), ContextMeeting(?cm) -> FamilyContact(?f), hasStatus(?f, "Reject")

which means "if user is in meeting then familycontact has status "reject". 这意味着“如果用户正在开会,则家庭联系人的状态为“拒绝”。

This syntax should work and protege doesn't show any error. 此语法应该可以工作,并且protege不会显示任何错误。 However, its not working. 但是,它不起作用。 And when i write 当我写

User(?u), isInActivity(?u, ?cm), ContextMeeting(?cm), FamilyContact(?f) -> hasStatus(?f, "Reject")

This syntax works perfectly but its useless when i write complex rules in such format. 当我以这种格式编写复杂的规则时,此语法可以完美地工作,但是它没有用。 Can anyone explain me the difference between the two formats and also give me a perfect solution? 谁能解释两种格式之间的区别,并给我一个完美的解决方案?

More explanation: 更多说明:

i have a main class People & subclasses of People are Contact & User . 我有一个主要的类PeoplePeople的子类是Contact和User The subclasses of Contact are FamilyContact, EmployeeContact etc. **The User and Contact are related by an object property isContactOf(People,Contact) .In my ontology there should be only one individual of class User . Contact的子类是FamilyContact,EmployeeContact等。** User和Contact由对象属性isContactOf(People,Contact)关联 。在我的本体中, User类应该只有一个人。 Now, i want to implement SWRL rules, ie If **user is in meeting then FamilyContact hasStatus "Reject".** This reject simply means that Family members can not call the user. 现在,我要实现SWRL规则,即, 如果**用户正在开会,则FamilyContact hasStatus“拒绝”。**此拒绝只是意味着Family成员无法呼叫用户。 Other rule is If user is in meeting then EmployeeContact hasStatus "Pass". 另一个规则是, 如果用户正在开会,则EmployeeContact hasStatus“ Pass”。 hasStatus(Contact,String) is a functional property. hasStatus(Contact,String)是一个功能属性。

the second rule syntax works perfectly, however when I want to implement a rule for those instances which are both EmployeeContact and FamilyContact then i get problem. 第二个规则语法可以完美地工作,但是当我想为EmployeeContact和FamilyContact的那些实例实施规则时,就会遇到问题。 eg if i write a rule ie 例如,如果我写了一条规则,即

User(?u), isInActivity(?u, ?cm), ContextMeeting(?cm), FamilyContact(?f), EmployeeContact(?e), DifferentFrom(?f,?e)-> hasStatus(?f, "Reject").

It works somehow but i get a problem. 它以某种方式工作,但我遇到了问题。 It makes the other instances of EmployeeContact also the Instances of FamilyContact and vice versa. 它使EmployeeContact的其他实例也成为FamilyContact的实例,反之亦然。

The rule 规则

User(?u) ∧ isInActivity(?u, ?cm) ∧ ContextMeeting(?cm) → FamilyContact(?f) ∧ hasStatus(?f, "Reject") User(?u)?isInActivity(?u,?cm)?ContextMeeting(?cm)→FamilyContact(?f)?hasStatus(?f,“ Reject”)

uses ?f in the right hand side (the consequent) of the rule, but not on the left (the antecedent). 在规则的右手边(结果)中使用?f,而不是在左手边(前件)中使用?f。 That's not allowed in the language (emphasis added): 该语言不允许(强调):

2.1. 2.1。 Rules 规则

Atoms may refer to individuals, data literals, individual variables or data variables. 原子可以指个体,数据文字,个体变量或数据变量。 Variables are treated as universally quantified, with their scope limited to a given rule. 变量被视为通用量化变量,其范围限于给定规则。 As usual, only variables that occur in the antecedent of a rule may occur in the consequent (a condition usually referred to as "safety"). 像往常一样,结果中仅可能出现在规则的前部发生的变量(通常称为“安全”的条件)。 This safety condition does not, in fact, restrict the expressive power of the language (because existentials can already be captured using OWL someValuesFrom restrictions). 实际上,此安全条件并不限制语言的表达能力(因为可以使用OWL someValuesFrom限制来捕获存在性)。

If it were legal, then your rule would mean: 如果这是合法的,那么您的规则将意味着:

For every u, cm, and f, 对于每个u,cm和f,

  • if u is a User and cm is a ContextMeeting and u is in cm, 如果 u是User且cm是ContextMeeting并且u以cm为单位,
  • then f is a family contact and has status "reject". 那么 f是家庭联系人,并且状态为“拒绝”。

But since there are no constraints on ?f, this says that any user is in any context meeting, then everything is a family contact with status "reject", and that's probably not what you want. 但是,由于对?f没有任何限制,因此,这意味着任何用户都可以参加任何上下文会议,那么一切都是状态为“拒绝”的家庭联系人,而这可能并不是您想要的。 Shouldn't ?f be related to ?u somehow? f是否应该以某种方式与u相关? The proposed alternative: 建议的替代方案:

User(?u) ∧ isInActivity(?u, ?cm) ∧ ContextMeeting(?cm) ∧ FamilyContact(?f) → hasStatus(?f, "Reject") 用户(?u)?isInActivity(?u,?cm)?ContextMeeting(?cm)?FamilyContact(?f)→hasStatus(?f,“拒绝”)

has a similar problem. 有类似的问题。 It would mean: 这意味着:

For every u, cm, and f, 对于每个u,cm和f,

  • if u is a User and cm is a ContextMeeting and u is in cm and f is a family contact, 如果 u是用户,cm是ContextMeeting,并且u以cm为单位,f是家庭联系人,
  • then f has status "reject". 那么 f的状态为“拒绝”。

There's still no connection between u and f, so this says that if any user is in any context meeting, then every family contact has status "reject". u和f之间仍然没有任何联系,因此这表示,如果任何用户在任何上下文中的会议中,则每个家庭联系人的状态均为“拒绝”。 That doesn't seem like what you'd want either. 这似乎也不是您想要的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM