Protege Using swrl:equal to compare the values of datatype property

孤街醉人 提交于 2019-12-25 16:03:14

问题


I am building an ontology of 3 classes :

  1. Messages
  2. Ham
  3. Spam

2 dataproperties , domain : Messages and range xsd:string :

  1. hasInterest
  2. hasCategory

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 ?


回答1:


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)


来源:https://stackoverflow.com/questions/43543913/protege-using-swrlequal-to-compare-the-values-of-datatype-property

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