Totally Lost while programming

83 views
Skip to first unread message

Anmol Mohak

unread,
Sep 6, 2022, 12:23:46 AM9/6/22
to CLIPSESG
Hello,
I am trying to write a programme in CLIPS regarding building a very basic and simple expert system for college students 
M goal are:
1.take name of person
2. What programme he or she is in like Btech ,Mtech ,MS ,Phd
3. what grades to they scored in there semesters
4. and finally according to college rules weather on basis of final grade students is eligible for degree or not.
Plz find an attachment where I have tried to do something.I am new to CLIPS so I am not able to solve my problem on my own.
Thank you
trail14.CLP

CLIPS Support

unread,
Sep 6, 2022, 5:58:14 PM9/6/22
to CLIPSESG
  1. Start by reading a tutorial to gain a basic understanding of the language. For CLIPS you can start with either the User's Guide (https://clipsrules.net/documentation/v640/ug640.pdf) or purchase a copy of Adventures in Rule-Based Programming (https://clipsrules.net/airbp.html).
  2. Don't write several hundred lines of code before checking for errors. If you're unfamiliar with a language, add code in the smallest increments possible. Test immediately and correct errors before adding more code.
  3. Don't invent or guess syntax. Use the reference manuals or working examples to determine the correct syntax. If your code is generating the same error message multiple times, that's an indication you need to code less and test/read more.
  4. Learn how to use a search engine. A web search of an error messages such as "Expected the beginning of a construct" will frequently find web pages explaining the error.
  5. There are hundreds of student projects written using CLIPS on github.com, many of which perform tasks similar to the program you're trying to create. The code quality varies, but in most cases they are free of syntax errors. 

Anmol Mohak

unread,
Sep 8, 2022, 7:33:51 AM9/8/22
to CLIPSESG
I am not able to get it and more correctly not able to identify .
can someone please search and send me one or two related to my project type

thank you

CLIPS Support

unread,
Sep 8, 2022, 3:58:02 PM9/8/22
to CLIPSESG
Nothing on GitHub is going to help you if you don't first learn how to identify and correct syntax errors in the code you write or modify. Regardless, here's a small program that asks a few questions, computes a value, and then provides an analysis of that value.

(deftemplate attribute
   (slot name)
   (slot value))

(defrule get-name
   =>
   (printout t "What is your name? ")
   (assert (attribute (name name) (value (read)))))
   
(defrule get-gender
   (attribute (name name) (value ?name))
   (not (attribute (name gender)))
   =>
   (printout t ?name ", what is your gender? ")
   (assert (attribute (name gender) (value (read)))))
   
(defrule get-total-cholestorol
   (attribute (name name) (value ?name))
   (not (attribute (name total-cholesterol)))
   =>
   (printout t ?name ", what is your total cholesterol? ")
   (assert (attribute (name total-cholesterol) (value (read)))))
   
(defrule get-HDL
   (attribute (name name) (value ?name))
   (not (attribute (name HDL)))
   =>
   (printout t ?name ", what is your HDL? ")
   (assert (attribute (name HDL) (value (read)))))
     
(defrule bad-answer
   (declare (salience 10))
   (or ?a <- (attribute (name gender) (value ~male&~female))
       ?a <- (attribute (name total-cholesterol | HDL)
                        (value ?value&:(or (not (numberp ?value))
                                           (<= ?value 0)))))
   =>
   (retract ?a))

(defrule compute-ratio
   (attribute (name total-cholesterol) (value ?total))
   (attribute (name HDL) (value ?hdl))
   =>
   (assert (attribute (name ratio) (value (/ ?total ?hdl)))))
   
(defrule low-ratio
   (attribute (name name) (value ?name))
   (or (and (attribute (name gender) (value male))
            (attribute (name ratio) (value ?ratio&:(< ?ratio 3.5))))
       (and (attribute (name gender) (value female))
            (attribute (name ratio) (value ?ratio&:(< ?ratio 3.0)))))
   =>
   (printout t ?name ", you have a low risk of heart disease." crlf))

(defrule moderate-ratio
   (attribute (name name) (value ?name))
   (or (and (attribute (name gender) (value male))
            (attribute (name ratio) (value ?ratio&:(>= ?ratio 3.5)&:(<= ?ratio 5.0))))
       (and (attribute (name gender) (value female))
            (attribute (name ratio) (value ?ratio&:(>= ?ratio 3.0)&:(<= ?ratio 4.4)))))
   =>
   (printout t ?name ", you have a moderate risk of heart disease." crlf))
   
(defrule high-ratio
   (attribute (name name) (value ?name))
   (or (and (attribute (name gender) (value male))
            (attribute (name ratio) (value ?ratio&:(> ?ratio 5.0))))
       (and (attribute (name gender) (value female))
            (attribute (name ratio) (value ?ratio&:(> ?ratio 4.4)))))
   =>
   (printout t ?name ", you have a high risk of heart disease." crlf))


Here's the output when running the program:

CLIPS> (load cholesterol.clp)
%*********
TRUE
CLIPS> (reset)
CLIPS> (run)
What is your name? Fred
Fred, what is your gender? male
Fred, what is your total cholesterol? 180
Fred, what is your HDL? 50
Fred, you have a moderate risk of heart disease.
CLIPS> 

Robert Kylberg

unread,
Sep 8, 2022, 5:31:33 PM9/8/22
to clip...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "CLIPSESG" group.
To post to this group, send email to CLIP...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/CLIPSESG?hl=en
 
--> IF YOU NO LONGER WANT TO RECEIVE EMAIL <--
Visit this group at http://groups.google.com/group/CLIPSESG?hl=en
Click on "Edit my membership" link.
Select the "No Email" radio button.
Click the "Save these settings" button.

--> IF YOU WANT TO UNSUBSCRIBE <--
Visit this group at http://groups.google.com/group/CLIPSESG?hl=en
Sign in
Click on "Edit my membership" link.
Click the "Unsubscribe" button.
Note: This appears to be the most reliable way to unsubscribe
 
Alternately, send email to CLIPSESG-u...@googlegroups.com. You will receive an email which you must respond to as well to unsubscribe. Clicking the link mentioned in the unsubscribe reply does not appear to work reliably.
---
You received this message because you are subscribed to the Google Groups "CLIPSESG" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clipsesg+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clipsesg/f796d10b-db0f-4e52-b697-7dad87a32e0en%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages