Халид
Халид

Reputation: 3

Expert System in Clips doesn't work

In my expert system user must check Developer and Price after he'll see notebook which is suitable for this parameters.

For example with this parameters (on screenshot) I must have result: Model: Noteebok1

Screenshot

But I don't see anything. Where is a problem or bug?

CLP File Code:

(defglobal ?*s* = 0)
(deftemplate Notebook
(slot pModel)
(slot pDeveloper)
(slot pPrice))
;*******************************************************************      
(deffunction QuestionOf(?TextQuestion $?variations)
(printout t ?TextQuestion)
(bind ?Answer (read))
(if (lexemep ?Answer)
then (bind ?Answer (lowcase ?Answer)))
(while (not (member ?Answer ?variations)) do
(printout t ?TextQuestion)
(bind ?Answer (read))
(if (lexemep ?Answer) 
then (bind ?Answer (lowcase ?Answer))))
?Answer)
;********************************************************************'
(defrule banner
(declare (salience 10))
=>(load-facts D:\fact.txt)
(printout t crlf crlf)
(printout t "Expert system. Nout search")
(printout t crlf crlf))
;******************************************************************'
(defrule QuestionDeveloper
(not (Developer ?))
=>(bind ?asssert(QuestionOf "Check Developer (a-HP,b-Samsung,c-Apple,d-IDontKnow)"  a b c d))
(if (eq ?asssert a)then (assert (Developer HP)))
(if (eq ?asssert b)then (assert (Developer Samsung)))
(if (eq ?asssert c)then (assert (Developer Apple)))
(if (eq ?asssert d)then (assert (Developer IDontKnow))))
;******************************************************************'
(defrule QuestionPrice
(not (Price ?))
=>(bind ?asssert(QuestionOf "Price?(a-300,b-400,c-500,d-IDontKnow)"  a b c d))
(if (eq ?asssert a)then (assert (Price 300)))
(if (eq ?asssert b)then (assert (Price 400)))
(if (eq ?asssert c)then (assert (Price 500)))
(if (eq ?asssert d)then (assert (Price IDontKnow))))
;******************************************************************'
(defrule Vyvod
(or (Developer ?xDeveloper)(Developer IDontKnow))
(or (Price ?xPrice)(Price IDontKnow))
(Notebook(pModel ?Model)(pDeveloper ?xDeveloper)(pPrice ?xPrice))
=>(bind ?*s*(+ ?*s* 1))
(printout t crlf "  " ?*s* ".  Model : " ?Model crlf))
;******************************************************************' 

Fact.txt:

(Notebook(pModel Notebook1)(pDeveloper HP)(pPrice 500))
(Notebook(pModel Notebook2)(pDeveloper Samsung)(pPrice 400)) 
(Notebook(pModel Notebook3)(pDeveloper Apple)(pPrice 500))

Upvotes: 0

Views: 393

Answers (1)

Gary Riley
Gary Riley

Reputation: 10757

The facts from the file fact.txt are not being loaded. Check that the file is at the specified path and that you have read access.

Upvotes: 0

Related Questions