Reputation: 29
I am building an ontology of 3 classes :
2 dataproperties , domain : Messages and range xsd:string :
2 SWRL Rules: Message(?x),hasInterest(?x,?a),hasCategory(?x,?b), swrl:equal(?a,?b) ->Ham(?x)
Message(?x),hasInterest(?x,?a),hasCategory(?x,?b), swrl:notEqual(?a?b) ->Spam(?x)
I want to classify instances of class Message to class Spam or Ham ; if the hasCategory value ( message category) is equal to the hasInterest value ( user interests) then the message is ham else spam
This worked correctly If I have 1 message category and 1 interest ex: m1 hasInterests sports m1 hasCategory sports
So what If I have a list of iterests or categories ex: Each message has more than 1 interests {sports, movies} Each message has more than 1 category {movies , politics}
I want to say if both lists intersect then the message is ham so the swrl:equal did not work how can i define it to compare all the individuals
What I did is repeating the hasInterests and hasCategory depending on the individual values I mean defining manually the list and it worked , is there another automatic way using a list of strings and how to compare them in swrl ?
Upvotes: 0
Views: 2149
Reputation: 21
SWRL Built-Ins for Strings (http://www.daml.org/rules/proposal/builtins.html) only support simple string functions.
In your model you can model a message individual m1
with many interests and many categories like this:
m1 hasInterests "sports", m1 hasInterests "movies"
m1 hasCategory "sports", m1 m1 hasCategory "movies"
and with your rule
Message(?x),hasInterest(?x,?a),hasCategory(?x,?b), swrl:equal(?a,?b) ->Ham(?x)
every message with at least one interest equal to a category becomes Ham
.
Perhaps useful hint to find number of interests but with the SQWRL Query:
Message(?x) ^ hasInterest(?x,?a) → sqwrl:select(?x) ^ sqwrl:count(?a)
Upvotes: 1