-1

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'
yolenoyer
  • 8,797
  • 2
  • 27
  • 61
Jaleh
  • 3
  • 2

1 Answers1

0
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> 
Gary Riley
  • 10,130
  • 2
  • 19
  • 34
  • Thank's a lot. Do I convert all if-then clauses to switch clause in the code? – Jaleh Dec 06 '15 at 13:45
  • Would you please answer another question? I load my clp file but it return false again. Do we must execute the program like you? It means step by step. At first deffact..then defrule..then... please tell me more. sincerely. – Jaleh Dec 06 '15 at 14:01
  • You don't have to use a switch statement, but since part of your problem was not properly balancing the left and right parentheses of your nested if statements, I'd suggest using switch instead. – Gary Riley Dec 06 '15 at 17:58
  • Read up on how to ask good questions: http://stackoverflow.com/help/how-to-ask. The vagueness of your original question was probably why it was down voted. – Gary Riley Dec 06 '15 at 18:01