FernandoRT
FernandoRT

Reputation: 1

I get a syntax error when executing the code using clipspy

I don't see the bug in the syntax of the program, the error I get is this:

Reglas.CLP, Line 6: Syntax Error:  Check appropriate syntax for defrule.  ERROR: (defrule MAIN::DormitorioIluminación_Encender    ?d <- (Dormitorio (Presencia Si) (Iluminación Apagada))    ?o <- (Otras (

Python code:

import clips

DEFTEMPLATE_STRING = """
(deftemplate Dormitorio
    (slot Presencia (type SYMBOL))
    (slot Iluminación (type SYMBOL)))
"""
"""
(deftemplate Otras
    (slot Hora (type INTEGER))
    (slot Estación (type SYMBOL)))
"""

env = clips.Environment()
env.build(DEFTEMPLATE_STRING)
env.load('Reglas.CLP')
Dormitorio = env.find_template('Dormitorio')
fact_Dormitorio = Dormitorio.assert_fact(Presencia = clips.Symbol('Si'),
                                        Iluminación = clips.Symbol('Apagada'))

Otras = env.find_template('Otras')
fact_Otras = Otras.assert_fact(Hora = '2000',
                                Estación = clips.Symbol('Verano'))

env.run()  

CLIPS code:

(defrule Regla1
    ?d <-   (Dormitorio 
                (Presencia Si)
                (Iluminación Apagada))
    ?o <-   (Otras
                (Hora ?Hora))
            (test (and (>= ?Hora 1800) (< ?Hora 2300)))
=>
(printout t "Encender la iluminación del dormitorio." crlf)
(modify ?d (Iluminación Encendida))
)

What is the error?

Upvotes: 0

Views: 85

Answers (1)

Gary Riley
Gary Riley

Reputation: 10757

You can't place multiple constructs in your call in the string you pass to the build method. The deftemplate Dormitorio is getting defined but not Otras.

Upvotes: 0

Related Questions