如何在CLIPS中定义defrule

时间:2015-05-12 20:59:58

标签: decision-tree clip clips expert-system

(defrule amphibian "" 
(water-aniaml yes)
(aquatic yes)
(eats-instencts no)
(not(guess ?))
=>
(assert (guess("guess not amphibian"))))

    (defrule skin-dddeceptionn "" 
(water-aniaml yes)
(aquatic yes)
(eats-instencts yes)
(has-four-legs yes)
(has-long-tongue yes)
(can-jump yes)
(has-poison no)
(skin-deception yes)
(not(guess ?))
=>
(assert (guess( "guess it's european common toad frog"))))

**我收到了这个错误 [PRNTUTIL2]语法错误:检查适当的defrule语法。 错误: (默认MAIN :: not-skin-ddeceptionn“”    (或(water-aniaml是)         (水生是)         (吃了 - 是的)         (有四条腿是)         (有长舌)         (可以跳是)         (有毒无)         (皮肤欺骗没有)         (不是(猜?))         => **

什么是错的,我试图使用或者它仍然是错误的(或)和没有(或) 我怎样才能解决这个问题>> ?????请帮帮忙?!!!

1 个答案:

答案 0 :(得分:0)

如果错误消息中未显示整个规则,则显示的最后一个令牌通常是错误消息的原因:

CLIPS> 
(defrule amphibian "" 
   (water-aniaml yes)
   (aquatic yes)
   (eats-instencts no)
   (not(guess ?))
   =>
   (assert (guess("guess not amphibian"))))

[EXPRNPSR1] A function name must be a symbol

ERROR:
(defrule MAIN::amphibian ""
   (water-aniaml yes)
   (aquatic yes)
   (eats-instencts no)
   (not (guess ?))
   =>
   (assert (guess ("guess not amphibian"
CLIPS> 

在这种情况下,显示的最后一个标记是“猜不是两栖动物”。因为您在此标记之前放置了左括号,CLIPS认为它是函数调用。由于函数名称是符号而不是字符串,因此字符串“guess not amphibian”是一个无效的函数名称,您将收到错误消息“[EXPRNPSR1]函数名称必须是符号”。

从规则中删除无关的括号将解决问题:

CLIPS> 
(defrule amphibian "" 
   (water-aniaml yes)
   (aquatic yes)
   (eats-instencts no)
   (not(guess ?))
   =>
   (assert (guess "guess not amphibian")))
CLIPS>