I'm new in Clips. I'd like to know if it is a way to read an array (chain of numeric or characters with an index, sorry if it's the wrong name) on LHS. I have rules to ask for a value (s,cs,cn,n) then it assert the value to next asking rule, to finally read all the values in an answering rule to get a diagnostic, but in my small example I have 4 questions and 4 options for each one so mixing all the answers would give me 64 rules, and I have so at least 30 questions in my program so I think that would be too much rules (I'm doing my first Expert System an maybe this is normal). In any case I think I could get the values from questions into an array an read it in answering rules, but my questions are:
*How can I bind the values from my function into an array?
*Is it possible to verify that array in LHS?
*Do you have any other idea to verify the answer-rules? Hope you can help me.
(deffunction funcionPregunta (?pregunta $?valoresAceptados) ;;ask-question function
(printout t ?pregunta)
(bind ?respuesta (read))
(if (lexemep ?respuesta)
then (bind ?respuesta (lowcase ?respuesta)))
(while (not (member$ ?respuesta ?valoresAceptados)) do
(printout t ?pregunta)
(bind ?respuesta (read))
(if (lexemep ?respuesta)
then (bind ?respuesta (lowcase ?respuesta))))
?respuesta)
;;===============================================================
;; QUESTION RULES
;;===============================================================
(defrule pregunta1T5 "AGORAFOBIA"
(not (diagnostico ?))
=>
(assert (Pregunta2T5
(funcionPregunta "1.Siente miedo o ansiedad marcada. (always/frecuently/rare/never)? "
s cs cn n))))
(defrule Pregunta2T5 "AGORAPUBLICO"
(not (diagnostico ?))
(Pregunta2T5 ?Pregunta2T5)
=>
(assert (Pregunta3T5
(funcionPregunta "2.Siente miedo en una multitud. (always/frecuently/rare/never)? "
s cs cn n)))
)
(defrule Pregunta3T5 "AGORAMIEDO"
(not (diagnostico ?))
(Pregunta3T5 ?Pregunta3T5)
=>
(assert (Pregunta4T5
(funcionPregunta "3.Miedo de estar en una situacion. (always/frecuently/rare/never)? "
s cs cn n)))
)
(defrule Pregunta4T5 "AGORAANSIEDAD"
... ;; similar rules
;;===============================================================
;; ANSWERS RULES
;;===============================================================
(defrule Respuesta1T6 "RESULTADO 1 TAS"
(not (diagnostico ?))
(Pregunta2T6 s)(Pregunta3T6 s)(Pregunta4T6 s)(Pregunta5T6 s)
=>
(assert (diagnostico "TRASTORNO DE ANSIEDAD SOCIAL"))
)
(defrule Respuesta2T6 "RESULTADO 2 TAS"
(not (diagnostico ?))
(Pregunta2T6 cs)(Pregunta3T6 s)(Pregunta4T6 s)(Pregunta5T6 s)
=>
(assert (diagnostico "TRASTORNO DE ANSIEDAD SOCIAL"))
)