【问题标题】:CLIPS Error: Illegal use of the module specifier when defruleCLIPS 错误:defrule 时非法使用模块说明符
【发布时间】:2020-07-22 07:50:59
【问题描述】:

我想定义一些模块规则来断言模块事实,然后通过get-fact-list批量获取一组事实列表,但是发生了错误!

         CLIPS (6.31 6/12/19)
CLIPS> (defmodule M)
CLIPS> (deftemplate M::T (slot k1))
CLIPS> (defrule M::T (testvalue 1) => (assert (M::T (k1 "v1"))))

[MODULDEF1] Illegal use of the module specifier.

ERROR:
(defrule M::T
   (testvalue 1)
   =>
   (assert (M::T
CLIPS> 

预期:

CLIPS> (defmodule M)
CLIPS> (deftemplate M::T (slot k1))
CLIPS> (defrule M::T (testvalue 1) => (assert (M::T (k1 "v1"))))

CLIPS> (assert (testvalue 1))
CLIPS> (get-fact-list M)
;; return the facts that M::rulexx  assert

为什么是语法错误? moduledefrule怎么办?

【问题讨论】:

    标签: rules rule-engine clips expert-system


    【解决方案1】:

    不要在你的断言命令中使用 M::T。由于 defrule 包含在模块 M 中,所有对 M 可见的 deftemplates 都可以在不使用模块说明符的情况下引用。

             CLIPS (6.31 6/12/19)
    CLIPS> (defmodule M)
    CLIPS> (deftemplate M::T (slot k1))
    CLIPS> (defrule M::T (testvalue 1) => (assert (T (k1 "v1"))))
    CLIPS> (assert (testvalue 1))
    <Fact-1>
    CLIPS> (get-fact-list M)
    (<Fact-1>)
    CLIPS>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-23
      • 2023-01-11
      • 2022-08-19
      • 1970-01-01
      • 2021-05-19
      • 2021-09-10
      • 2023-02-16
      • 2022-11-06
      相关资源
      最近更新 更多