Jsevillamol
Jsevillamol

Reputation: 2543

Using an integer slot in Protege in a Jess rule

I have written the following Jess rule to use it in a Protege ontology.

(mapclass Cliente)
(defrule perfil-familia-numerosa

    ?cliente <- (object (is-a Cliente) 
        (nombre ?name) 
        (discapacidad? ?discapacity)
        (distrito_deseado ?desired_district)
        (n_miembros_familia ?n)
        (presupuesto_maximo ?max)
        (presupuesto_minimo ?min))
    (test (> n 4))
    =>
    (assert (perfil-cliente ?name soltero)))

When I try entering it in the Jess tab, I get a type error Jess reported an error in routine > [...] java.lang.Integer cannot be cast to java.lang.String.

However, the slot in question is an Integer, so it is not clear to me why Jess it's treating it as a String. Any help?

Upvotes: 0

Views: 53

Answers (1)

laune
laune

Reputation: 31290

The problem is here:

(test (> n 4))

A reference to a bound variable retains the '?', so you have to write

(test (> ?n 4))

However, it might be better to add this constraint to (n_miembros_familia ?n).

(n_miembros_familia ?n&:(> ?n 4))

Upvotes: 2

Related Questions