【问题标题】:how to define defrule in CLIPS如何在 CLIPS 中定义 defrule
【发布时间】:2015-07-23 22:36:57
【问题描述】:
(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 的适当语法。 错误: (defrule MAIN::not-skin-ddeceptionn "" (或 (water-aniaml 是的) (水生是) (吃——是的) (有四脚是的) (有长舌是的) (可以跳是的) (有毒无) (皮肤欺骗没有) (不是(猜?)) => **


出了什么问题,我尝试使用 or 但使用 (or) 和不使用 (or) 时仍然出错 我该如何解决这个问题>>?????请帮忙?!!!

【问题讨论】:

    标签: decision-tree clip clips expert-system


    【解决方案1】:

    如果错误消息中没有显示整个规则,那么显示的最后一个标记通常是错误消息的原因:

    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 ampphibian”是无效的函数名,您会收到错误消息“[EXPRNPSR1] A function name must be a symbol”。

    从规则中删除多余的括号将更正问题:

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

    【讨论】:

    • 在命令提示符下输入更正后的规则对您有用吗?如果是这样,那么您需要提供有关导致错误发生的原因的更多详细信息。您已经显示了两条错误规则的代码,即两栖类和 skin-dddeceptionn,您引用的错误消息是第三条:not-skin-ddeceptionn。这使问题变得混乱。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多