Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;;;======================================================
- ;;; Author Iliya Popov
- ;;; Data created 1.12.2021
- ;;; sample jess diagnostic system
- ;;;======================================================
- ;;****************
- ;;* Deffunctions *
- ;;****************
- (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)
- (deffunction yes-or-no (?question)
- (bind ?response (ask-question ?question да не д н))
- (if (or (eq ?response да) (eq ?response н))
- then да
- else не))
- ;;;************************
- ;;;* Ask the patient rules *
- ;;;************************
- (defrule symptom-constant-hunger "Симптом Непренстанен глад"
- (not (answer ?))
- (not (diagnoses ?))
- =>
- (assert (constant-hunger (yes-or-no "Мъче ли Ви непренстанен глад (да/не)? ")))
- )
- (defrule symptom-tormenting-thirst "Симптом Мъчителна жажда"
- (not (answer не))
- (not (diagnoses ?))
- =>
- (assert (painful-thirst (yes-or-no "Имате ли мъчителна жажда (да/не)? ")))
- )
- (defrule symptom-dry-mouth "Сухота в устата"
- (not (answer не))
- (not (diagnoses ?))
- =>
- (assert (dry-mouth (yes-or-no "Получавате ли сухота в устата (да/не)? ")))
- )
- ;;;*******************
- ;;;* Diagnoses rules *
- ;;;*******************
- (defrule normal-patients-symptoms ""
- (painful-thirst не)
- (constant-hunger не)
- (dry-mouth не)
- (not (diagnoses ?))
- =>
- (assert (diagnoses "Вие не сте болен от диабет тип 1.")))
- (defrule patients-symptoms ""
- (painful-thirst да)
- (constant-hunger да)
- (dry-mouth да)
- (not (diagnoses ?))
- =>
- (assert (diagnoses "Вие сте болен от диабет тип 1.")))
- (defrule no-diagnoses ""
- (declare (salience -10))
- (not (diagnoses ?))
- =>
- (assert (diagnoses "
- Моля отидете на лекар.")))
- ;;;********************************
- ;;;* Run and conclusion rules *
- ;;;********************************
- (defrule system-banner ""
- (declare (salience 10))
- =>
- (printout t crlf "Експертна система за дигностициране на пациент за диабет тип 1" crlf))
- (defrule print-diagnoses ""
- (declare (salience 10))
- (diagnoses ?item)
- =>
- (printout t crlf "
- Диагноза:" crlf)
- (printout t " " ?item crlf))
- (reset)
- (run)
Advertisement
Add Comment
Please, Sign In to add comment