riad
riad

Reputation: 371

equal instruction inside SWRL rule not working

I am using Protege 4.3 to make some SWRL rules.

I have one class called "Person" with one property called "name".

I created individuals from the class with different names, and some names are the same.

I want to write a rule that creates instances of Property called "sameName" to bind people who have the same name. So I wrote the following rule :

Person(?p1), Person(?p2), name(?p1, ?n1), name(?p2, ?n2), equal(?n1, ?n2) -> sameName(?p1, ?p2)

The rule gave the right result but includes every person with himself, means compares also every person with himself, so I added notEqual(?p1,?p2) to force the reasoner to not compare a person with himself like this:

Person(?p1), Person(?p2), name(?p1, ?n1), name(?p2, ?n2), equal(?n1, ?n2), notEqual(?p1, ?p2) -> sameName(?p1, ?p2)

The result was empty. Did I miss something?

Upvotes: 0

Views: 823

Answers (1)

Sven Hazard
Sven Hazard

Reputation: 23

I guess you should set all the individuals be different. If you did not do that, the reasoner could not judge whether two individuals are same or not, so the SWRL rules you wrote did not work at all.

Upvotes: 1

Related Questions