clipsexpert-system

I want this Clips program to compare 4 symptoms of disease using if then(the symptoms are ows, yhp, sda and dgb)


I want this Clips program to compare 4 symptoms of a disease Bacterial fruit blotch of watermelon using if then rules of Clips (the symptoms are ows, yhp, sda and dgb). the issue is when I run the code it does not display anything. below is the sample code. I need your help please.

(defrule bacterial-fruit-blotch-of-watermelon 
   (initial-fact)
   (printout t "is the plant showing a symptom of Oily and water-soaked cotyledons" crlf)
   (printout t "is the plant showing a symptom of Yellow halo paralleling veins " crlf)
   (printout t "is the plant showing a symptom of Small dark and angled lesion on leaves " crlf)
   (printout t "is the plant showing a symptom of Dark green blotch on the upper surface of developing fruit " crlf)
   =>
   (assert (OWS (read)))
   (assert (YHP (read)))
   (assert (SDA (read)))
   (assert (DGB (read))))
CLIPS>
(defrule check
   (ows ?OWS)
   (yhp ?YHP)
   (sda ?SDA)
   (dgb ?DGB)
   => 
   (if (and (eq ?OWS yes)
   (and (eq ?YHP yes)
   (and (eq ?SDA yes)
   (eq ?DGB yes))))
   then
   (printout t "The plant is showing a symptom of bacterial fruit blotch of watermelon disease " crlf)
clips>(run)

Solution

    1. Don't use the initial-fact pattern in rules.
    2. The printout statements should be in the actions of the rule, not the conditions.
    3. If you're printing to standard output, you can use the print and println functions rather than printout.
    4. Matching is case sensitive, so OWS will not match ows.
    5. Checking for yes in the conditions of the rule, rather than the actions, simplifies the rule and prevents it from being activated if any of the responses is not yes.

    With these changes the rule will execute:

             CLIPS (6.4 2/9/21)
    CLIPS> 
    (defrule bacterial-fruit-blotch-of-watermelon 
       =>
       (print "Is the plant showing a symptom of Oily and water-soaked cotyledons? ")
       (assert (OWS (read)))
       (print "Is the plant showing a symptom of Yellow halo paralleling veins? ")
       (assert (YHP (read)))
       (print "Is the plant showing a symptom of Small dark and angled lesion on leaves? ")
       (assert (SDA (read)))
       (print "Is the plant showing a symptom of Dark green blotch on the upper surface of developing fruit? ")
       (assert (DGB (read))))
    CLIPS> 
    (defrule check
       (OWS yes)
       (YHP yes)
       (SDA yes)
       (DGB yes)
       => 
       (println "The plant is showing a symptom of bacterial fruit blotch of watermelon disease."))
    CLIPS> (reset)
    CLIPS> (run)
    Is the plant showing a symptom of Oily and water-soaked cotyledons? yes
    Is the plant showing a symptom of Yellow halo paralleling veins? yes
    Is the plant showing a symptom of Small dark and angled lesion on leaves? yes
    Is the plant showing a symptom of Dark green blotch on the upper surface of developing fruit? yes
    The plant is showing a symptom of bacterial fruit blotch of watermelon disease.
    CLIPS>