alex
alex

Reputation: 7905

SWRL: restrict a rule to a specific individual

Lets say there is a class "Food" containing individuals "Grain" and "Fruit" . If i want to select Grain i can assign a food_type data Property to individuals

(class) Food
    (ind_1) Grain   food_type ---> "grain_food"
    (ind_2) Fruit   food_type ---> "fruit_food"

and run this code:

  Food(?x) ^ food_type(?x,"grain_food") -> sqwrl:select(?x)

but what if i want to do this job (select Grain individual) without the needing to food_type property? is it possible to directly point to a specific individual just by its name?

Upvotes: 2

Views: 610

Answers (1)

Joshua Taylor
Joshua Taylor

Reputation: 85883

It's not exactly clear what you're asking, but yes, you can use an individual in a SWRL rule. E.g., if you have an individual c from class C, you can do:

    C(c) ⟶ sqwrl:select(c)

As long as sqwrl:select doesn't necessarily require a variable (i.e., as long as it can accept an individual directly), this should be fine. If it requires a variable, as opposed to an individual directly (which would go against the intent, I think), I guess you could use some kind of equality predicate, like swrbl:equal:

    swrlb:equal(c,?x) ⟶ sqwrl:select(?x)

Upvotes: 3

Related Questions