protegejess

Matching an abstract class in Jess Tab Protege


In my Protege ontology, I have an abstract class Building with concrete children classes Chalet and Apartment.

I want to match them to the LHS of a Jess rule, but I cannot get it to work.

My attempt is as follows:

(mapclass Building)
(defrule dummy
    ?vivienda <- (object (is-a Building))
    =>
    (assert (it-worked))
)

The rule does not give any parsing error, but it does not match any of my Building instances. What am I doing wrong?


Solution

  • You can only match an instance with the most specific class. If you want to match all instances of a superclass you need to check it explicitly.

    As specified in the JessTab documentation there is a boolean function called superclassp that checks if a class is the superclass of a second class. In your example:

    (mapclass Building)
    (defrule dummy
        ?vivienda <- (object (is-a ?subclass))
        (test (superclassp Building ?subclass))
        =>
        (assert (it-worked))
    )