CLIPS “Expected the beginning of a construct”

时光总嘲笑我的痴心妄想 提交于 2019-12-04 03:42:06

问题


I have this homework(I'm a student), in CLIPS, however I can't make any progress, despite searching on google, and spending some time on it.

(clear)
(deftemplate book
    (multislot surname)(slot name)(multislot title) 
)

(book (surname J.P.)(name Dubreuil)(title History of francmasons))
(book (surname T.)(name Eker)(title Secrets of millionaire mind))

(defrule find_title
    ?book<-(book(name Eker))
    =>
    (printout t ?book crlf)
)

What I eventually get is this error: "Expected the beginning of a construct". Any ideas please?


回答1:


If you're using the load command to load this content, then you're mixing commands (such as clear) with CLIPS constructs (such as deftemplate and defrule). To fix this, first create a file such as book.clp with just constructs:

(deftemplate book
    (multislot surname)(slot name)(multislot title) 
)

(deffacts initial
(book (surname J.P.)(name Dubreuil)(title History of francmasons))
(book (surname T.)(name Eker)(title Secrets of millionaire mind)))

(defrule find_title
    ?book<-(book(name Eker))
    =>
    (printout t ?book crlf)
)

Then you can use the load command to load the file and run it:

CLIPS> (clear)
CLIPS> (load book.clp)
%$*
TRUE
CLIPS> (reset)
CLIPS> (agenda)
0      find_title: f-2
For a total of 1 activation.
CLIPS> (facts)
f-0     (initial-fact)
f-1     (book (surname J.P.) (name Dubreuil) (title History of francmasons))
f-2     (book (surname T.) (name Eker) (title Secrets of millionaire mind))
For a total of 3 facts.
CLIPS> (run)
<Fact-2>
CLIPS> 


来源:https://stackoverflow.com/questions/19332952/clips-expected-the-beginning-of-a-construct

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!