我有这个作业(我是一名学生),在 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)
)
我最终得到的是这个错误:“预期构造的开始”。 请问有什么想法吗?
如果您使用 load 命令来加载此内容,那么您将命令(例如clear)与CLIPS 构造(例如deftemplate 和defrule)混合在一起。要解决此问题,首先创建一个仅包含构造的文件,例如 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)
)
然后就可以使用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>
任何人都可以帮助我吗?
我有,Lab3 - 负载1:
(deftemplate persoana(slot nume)(slot varsta)(slot culoare_par)(slot culoare_ochi))
Lab3 - 加载 2:
(clear)
(load Lab3 - load1.clp)
(assert(persoana(nume "John")(varsta 25)(culoare_par "brunet")(culoare_ochi "albastri")))
(assert(persoana(nume "Alice")(varsta 30)(culoare_par "blond")(culoare_ochi "verzi")))
(facts)
(retract 1)
(modify 2(varsta 32))
(printout t "Suma a doua numere: " (+ 5 3) crlf)
但是,当我加载 load1 文件时: CLIPS>(加载“C:/Users/Cristian/Desktop/Facultate/IA CLIPS 6.3 Laboratoare/Lab 3 CLIPS/Lab3 - load1.clp”) 定义 deftemplate:角色 正确
当我加载下一个文件时,加载2: CLIPS>(加载“C:/Users/Cristian/Desktop/Facultate/IA CLIPS 6.3 Laboratoare/Lab 3 CLIPS/Lab3 - load2.clp”)
[CSTRCPSR1] 预期构造的开始。 错误
为什么?这个应用程序有什么问题吗?..