Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
212 views
in Technique[技术] by (71.8m points)

Expert system clips code return false value

I have an expert system for diagnosing some disease.

It's coded in clips. But this code didn't run in clips and return false statement at the end of the run. I trace it again and again but I didn't notice what is the problem.

Here is some part of my code: please help me. sincerely.

`(deffacts init (start)) `
'(Defining defrule mainmenu '
'(start) '
'?ml <- (start) '
'=> '
'(printout t crlf crlf crlf crlf crlf crlf)'
'(printout t '
'"an expert system for diagnosis of some skin '
'disease" crlf crlf'
'"               Main Menu" crlf'
'"                ==========crlf crlf crlf'
'"         1-Skin rashes without fever" crlf crlf'
'"         2- Skin rashes with fever" crlf crlf'
'"         3- Skin infection " crlf crlf crlf'
'"         0- Quit the program " crlf crlf'
'"Type number of your choice then hit return key" crlf crlf'
'" Choice: ")'
'(bind ?response (read))'
'(if (eq ?response 1)'
'then (assert (type 0-1))'
'else'
'(if (eq ?response 2) then (assert (type 0-2)))'
'else '
'(if (eq ?response 3) then (assert (type 0-3)))'
'else'
'(if (eq ?response 0) then (assert (type quit)))'
'(printout t crlf)'
'(retract ?ml))'
'(Defining defrule user-quits'
'(type quit)'
'=>'
'(printout t "you have QUIT the program." crlf)'
'(halt))'
'((Defining defrule without'
'?p <- (type 0-1)'
'=>'
'(printout t crlf crlf crlf)'
'(retract ?p)'
'"printout t'
'"      Diagnosis of some skin desease " crlf crlf crlf'
'"      Skin rashes without fever menu" crlf'
'"      ==================================" crlf'
'crlf'
'"      1- red patches of skin , painful joints, " crlf'
'"         pitted nails, poorly controlled dandruff" crlf'
'crlf'
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
CLIPS> (deffacts init (start)) 
CLIPS> 
(defrule mainmenu 
   ?ml <- (start) 
   => 
   (printout t crlf crlf crlf crlf crlf crlf)
   (printout t 
    "an expert system for diagnosis of some skin disease" crlf crlf
    "               Main Menu" crlf
    "               =========" crlf crlf crlf
    "         1- Skin rashes without fever" crlf crlf
    "         2- Skin rashes with fever" crlf crlf
    "         3- Skin infection " crlf crlf crlf
    "         0- Quit the program " crlf crlf
    "Type number of your choice then hit return key" crlf crlf
    " Choice: ")
   (bind ?response (read))
   (switch ?response
      (case 1 then (assert (type 0-1)))
      (case 2 then (assert (type 0-2)))
      (case 3 then (assert (type 0-3)))
      (case 0 then (assert (type quit))))
   (printout t crlf)
   (retract ?ml)))
CLIPS> 
(defrule user-quits
   (type quit)
   =>
   (printout t "you have QUIT the program." crlf)
   (halt))
CLIPS> (reset)
CLIPS> (run)






an expert system for diagnosis of some skin disease

               Main Menu
               =========


         1- Skin rashes without fever

         2- Skin rashes with fever

         3- Skin infection 


         0- Quit the program 

Type number of your choice then hit return key

 Choice: 0

you have QUIT the program.
CLIPS> 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...