2011/10/18 Vladimir Cvjetkovic
<vcvj...@gmail.com>
You could send me the whole listing, and I'll try to correct it and send it back.
Oh, it would be great!!!!!!!
here it is:
;====================================================
; Ekspertna sustema "Student"
;====================================================
;----------------------------------------------------
;====================================================
; Funktsiji
;====================================================
;===========Funktsija zaputannja=====================
;tsja funktsija zadaje zaputannja korustyva4y
(deffunction ask-question(?question $?allowed-values)
(printout t ?question)
(bind ?answer (read))
(if (lexemep ?answer)
then
(bind ?answer (lowcase ?answer)))
(while (not (member ?answer ?allowed-values)) do
(printout t ?question)
(bind ?answer(read))
(if (lexemep ?answer)
then
(bind ?answer(lowcase ?answer))))
?answer
)
;===================================================
;===========Funktsija tak-ni========================
;tsja funktsija zadaje putannja i otrumyje vidpovid
(deffunction Yes-No (?question)
(bind ?response (ask-question ?question yes no y n))
(if (or (eq ?response yes) (eq ?response y))
then
True
else
False)
)
;===================================================
;---------------------------------------------------
;===================================================
; Diagnostu4ni pravula
;===================================================
;==========Pravulo student==========================
;oprudiljaje do jakogo tupy vidnosutsja stydent
(defrule Y4en ""
(not (student ?))
(not (act ?))
=>
(if (Yes-No "Does the student have problems with eyes(yes/no)?")
then
(assert (student hardly see))
else
(if (Yes-No "Does the student have problems with hearing (Yes/No)?")
then
(assert (student hardly hear))
else
(if (Yes-No "Does the student have problems with moving (Yes/No)?")
then
(assert (act "make a lift"))
else
(if (Yes-No "Does the student have any other problems(Yes/No)?")
then
(assert (student has unknown problems))
else
(assert (student has no problems))
)
)
)
)
;===================================================
;==========Pravulo zdorovuj=========================
;oprudiljaje rishennja dlja stydenta bez problem
(defrule Zdorovuj ""
declare (salience 10))
(student has no problems)
(not (act ?))
=>
(assert (act "no changes")
)
;===================================================
;==========Pravulo zir =============================
;oprudiljaje rishennja dlja stydenta z poganum zorom
(defrule vision ""
(student hardly see)
(not (act ?))
=>
(if (Yes-No "Can the student see a litle (Yes/No)?")
then
assert (act "instal the MAGNIFYING GLASS on the computer")
else
assert (act "buy books for blind")
)
)
;===================================================
;==========Pravulo slyh=============================
;oprudiljaje rishennja dlja stydenta z poganum slyhom
(defrule hearing ""
(student hardly hear)
(not (act ?))
=>
(if (Yes-No "Can the student hear a litle (Yes/No)?")
then
assert (act "equip the class with microphone")
else
assert (act "print oll the lections")
)
)
;===================================================
;==========Pravulo ne zdorovuj=========================
;oprudiljaje rishennja dlja stydenta bez problem
(defrule nezdorovuj ""
declare (salience -1))
(student has unknown problems)
(not (act ?))
=>
(assert (act "ask for the advice, the program can't advice you")
)
;===================================================
;==========Pravulo zakin4ennja======================
;vuvodut resultat na ekran
(defrule conc ""