Am writing a program with CLIPS for expert system that will diagnose symptoms and conclude the type of disease affecting a watermelon plant. Now I want to use .NET to design a graphical user interface. so that the user will just use radio button to answer questions concerning the symptom of diseases in the form of yes/no and press a button labelled as analyse button to see the predicted disease affecting the watermelon plant. Below is the code that works for console. now I want the user to interact with it through interface. Please help.

(deftemplate symptom
   (slot id)
   (slot question)
   (slot indicative (default yes)))
(deffacts symptoms
   (symptom (id ows)
            (question "Is the plant showing a symptom of Oily and water-soaked cotyledons?"))
   (symptom (id yhp)
            (question "Is the plant showing a symptom of Yellow halo paralleling veins?"))
   (symptom (id sda)
            (question "Is the plant showing a symptom of Small dark and angled lesion on leaves?"))
   (symptom (id dgb)
            (question "Is the plant showing a symptom of Dark green blotch on the upper surface of developing fruit?"))
   (symptom (id corky)
            (question "Is the plant showing a symptom of corky, dry necrosis?"))
   (symptom (id misshaping)
            (question "Is the plant showing a symptom of misshapen?"))
   (symptom (id dark)
            (question "Is the plant showing a symptom of dark, water-soaked depression?"))
(symptom (id shiny)
            (question "Is the leaf showing a symptom of shiny, chlorotic halo?"))  
(symptom (id sil)
            (question "Does the leaf shows a symptom of small irregular lesions and became angular later?"))  
(symptom (id owb)
            (question "Is the plant showing a symptom of clorotic on watermelon boaders?"))
(symptom (id olb)
            (question "Is the plant showing a symptom of Older lesions that is usually brown, dry and  tear to produce a tattered appearance on leaf ?"))
   (symptom (id sri)
            (question "Is the leaf showing a symptom of Small, round to irregular, watersoaked spots appear on infected leaves?")) 
 (symptom (id sou)
            (question "Is the leaf showing a symptom of spots on the upper leaf surfaces turn whitish  gray to brown and die?"))
(symptom (id oll)
            (question "Is the leaf showing a symptom of gummy and shiny On the lower leaf surfaces?"))
)
(deftemplate disease
   (slot id)
   (multislot symptoms))
   
(deffacts diseases
   (disease (id "bacterial fruit blotch")
            (symptoms ows yhp sda dgb))
   (disease (id "bacterial rind necrosis")
            (symptoms corky misshaping dark))
(disease (id "angular leaf spot")
            (symptoms shiny sil owb olb sri sou oll))
)
(deftemplate answer
   (slot id)
   (slot value))

(deftemplate conclusion
   (slot id))
(defrule conclude-disease
   ;; There is a disease
   (disease (id ?disease))
   ;; For every symptom of that disease
   (forall (disease (id ?disease)
                    (symptoms $? ?symptom $?))
           (symptom (id ?symptom)
                    (indicative ?value))
           ;; There is a response indicative
           ;; of a problem
           (answer (id ?symptom)
                   (value ?value)))
   =>
   ;; Conclude the plant has the disease
   (assert (conclusion (id ?disease))))  
(deffunction ask-question (?question $?allowed-values)
  (printout t ?question " " ?allowed-values " ")
  (bind ?answer (read))
  (if (lexemep ?answer)
     then (bind ?answer (lowcase ?answer)))
  (while (not (member$ ?answer ?allowed-values)) do
     (printout t ?question " " ?allowed-values " ")
     (bind ?answer (read))
     (if (lexemep ?answer)
        then (bind ?answer (lowcase ?answer))))
  ?answer)

(defrule ask-symptom
   ;; There is a symptom
   (symptom (id ?symptom)
            (question ?question))
   ;; For a disease
   (disease (id ?disease)
            (symptoms $? ?symptom $?))
   ;; That we have not determined
   (not (answer (id ?symptom)))
   ;; And there is no prior response to a symptom
   ;; of that disease that is non-indicative.
   (not (and (disease (id ?disease)
                      (symptoms $? ?other-symptom $?))
             (symptom (id ?other-symptom)
                    (indicative ?value))
             (answer (id ?other-symptom)
                     (value ~?value))))
   =>
   ;; Ask the user the symptom question
   (bind ?value (ask-question ?question yes no))
   ;; And assert the response.
   (assert (answer (id ?symptom)
                   (value ?value))))
(defrule print-conclusion
   (declare (salience -10))
   (conclusion (id ?disease))
   =>
   (printout t "The plant is showing symptoms of " ?disease " watermelon disease." crlf))

(defrule print-no-conclusion
   (declare (salience -10))
   (not (conclusion))
   =>
   (printout t "The plant is not showing all symptoms of a watermelon disease." crlf))
0

There are 0 best solutions below