Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

DialogWindow4

.txt
Скачиваний:
1
Добавлен:
18.02.2023
Размер:
2.47 Кб
Скачать
(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-p (?question)
(bind ?response (ask-question ?question yes no y n))
(if (or (eq ?response yes) (eq ?response y))
then TRUE
else FALSE)
)

(defrule check-jobless
(not (jobless ?))
(not (recommendation ?))
=>
(if (yes-or-no-p "Does the borrower have a job? (yes/no): ")
then (assert (jobless NO))
else (assert (recommendation "It is recommended to refuse.")))
)

(defrule check-law-trouble
(jobless NO)
(not (recommendation ?))
=>
(if (yes-or-no-p "Does the borrower have a law trouble? (yes/no): ")
then (assert (recommendation "It is recommended to refuse."))
else (assert (law-trouble NO)))
)

(defrule check-negative
(law-trouble NO)
(not (recommendation ?))
=>
(if (yes-or-no-p "Does the borrower have other loans? (yes/no): ")
then (if (yes-or-no-p "Did the borrower delay the loan payments? (yes/no): ")
then (assert (recommendation "It is recommended to refuse."))
else (assert (negative NO)))
else (assert (negative NO)))
)

(defrule check-positive
(negative NO)
(not (recommendation ?))
=>
(if (yes-or-no-p "Does the borrower have a deposit? (yes/no): ")
then (assert (recommendation "It is recommended to approve."))
else (if (yes-or-no-p "Does the borrower have a property? (yes/no): ")
then (assert (recommendation "It is recommended to approve."))
else (if (yes-or-no-p "Did the borrower repay the loans ahead of schedule? (yes/no): ")
then (assert (recommendation "It is recommended to approve."))
else (assert (recommendation "It is recommended to refuse.")))))
)

(defrule print-recommendation
(declare (salience 10))
(recommendation ?item)
=>
(printout t crlf crlf)
(printout t "Recommendation:")
(printout t crlf crlf)
(format t " %s%n%n%n" ?item)
)

(defrule system-banner ""
(declare (salience 10))
=>
(printout t crlf crlf)
(printout t "********************************************" crlf)
(printout t "* The credit decision-making expert system *" crlf)
(printout t "********************************************" crlf)
(printout t crlf crlf)
)
Соседние файлы в предмете Интеллектуальные информационные системы