When I run the code I get this error:
clips.common.CLIPSError: [CSTRNCHK1] test.CLP, Line 7: A literal restriction value found in CE #1 does not match the allowed types for slot 'Presencia'. ERROR: (defrule MAIN::r1 ?d <- (dormitorio (Presencia Si) (Iluminación Apagada)) => (printout t "Encender la iluminación del dormitorio." crlf) (modify ?d (Iluminación Encendida))).
Python code:
import clips
DEFTEMPLATE_STRING = """
(deftemplate dormitorio
(slot Presencia (type STRING))
(slot Iluminación (type STRING)))
"""
env = clips.Environment()
env.build(DEFTEMPLATE_STRING)
env.load('test.CLP')
Dormitorio = env.find_template('dormitorio')
fact_Dormitorio = Dormitorio.assert_fact(Presencia = 'Si',
Iluminación = 'Apagada')
env.run()
Clips file:
(defrule r1
?d <- (dormitorio
(Presencia Si)
(Iluminación Apagada))
=>
(printout t "Encender la iluminación del dormitorio." crlf)
(modify ?d (Iluminación Encendida)))
Why does this error occur?
Si and Apagada are symbols. Strings are enclosed in quotation marks. Declare the types in the deftemplate as SYMBOL.