Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
638 views
in Technique[技术] by (71.8m points)

protege - Disjunction inside SWRL rule

I am using Protege 4.3 to make some SWRL rules. Is it possible to write a rule that contains a disjunction in it For instance :

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

Meaning all people having age < 10 OR > 30

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

axiom instead of rule


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...