我有这个功课(我是学生),在CLIPS中,但我无法取得任何进展,尽管在谷歌搜索,并花了一些时间在它上面.
(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)
)
Run Code Online (Sandbox Code Playgroud)
我最终得到的是这个错误:"预期构造的开始".有什么想法吗?
Gar*_*ley 10
如果您使用load命令加载此内容,那么您将使用CLIPS结构(例如deftemplate和defrule)混合命令(例如clear).要解决此问题,首先使用构造创建一个文件,例如book.clp:
(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)
)
Run Code Online (Sandbox Code Playgroud)
然后,您可以使用load命令加载文件并运行它:
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>
Run Code Online (Sandbox Code Playgroud)