Disjunction inside SWRL rule

回眸只為那壹抹淺笑 提交于 2019-11-29 13:08:25

You can't directly express a disjunction in the rule body the way that you'd like to, unfortunately, but there are some workarounds. The most direct solution is to write two rules:

Person(?x), Age(?x,?age), ?age < 10 -> blah(?x)
Person(?x), Age(?x,?age), ?age > 30 -> blah(?x)

SWRL does support the use of class expressions (see more in Martin Kuba's OWL 2 and SWRL Tutorial), so you could do this:

Person(?x), ((some Age xsd:integer[< 10]) or (some Age xsd:integer[> 30]))(?x) -> blah(?x)

but you won't be able to enter that rule in Protege, even though if you write it in some other ontology editor, or write it by hand, Protege can display it correctly. You could simply that even more and do this:

Person(?x), ((some Age (xsd:integer[< 10] or xsd:integer[> 30]))(?x) -> blah(?x)

or even father and do this:

(Person and (some Age (xsd:integer[< 10] or xsd:integer[> 30])))(?x) -> blah(?x)

Of course, at this point, depending on what blah(?x) is, you might be able to just use a general class axiom that Protege will accept. E.g., if blah is actually a class, Not10To30YearOldPerson, you can use an axiom like:

Person and (age some (xsd:integer[< 10] or xsd:integer[> 30])) subClassOf not TenToThirtyYearOldPerson

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!