CLIPS错误:断言模板xxx不存在

编程入门 行业动态 更新时间:2024-10-26 13:28:34
本文介绍了CLIPS错误:断言模板xxx不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述
  • CLIPS版本:6.31
  • 语言:c++ clips C API
  • CLIPS version: 6.31
  • language: c++ clips C API

为什么会出现此错误?我该如何解决该错误?

Why am I getting this error? How should I fix this error?

[FACTRHS1] Template be-contact-model.riskLevel does not exist for assert. Function load-facts encountered an error

过程如下:首先,我使用ClipsEnvLoadFromString函数从完整剪辑规则代码创建一个CLIPS环境,使用EnvLoadFactsFromString函数在此CLIPS环境中将获得正常结果.复制多个CLIPS环境, 因此我使用EnvBsave函数将规则保存在二进制映像文件中,然后使用EnvBload函数从二进制文件加载新环境,然后使用EnvLoadFactsFromString函数加载用户事实. EnvLoadFactsFromString函数返回false,并且cli stdout获得错误字符串:

The process is as follows: Firstly, I create a CLIPS environment from the full clips rule code using the ClipsEnvLoadFromString function, I will get a normal result in this CLIPS environment using the EnvLoadFactsFromString function.Next I want to copy more than one CLIPS environment, so I save the rules in a binary image file using the EnvBsave function and then I load a new environment from a binary file using EnvBload function, and then I use the EnvLoadFactsFromString function to load the user facts.But the EnvLoadFactsFromString function return false, and the cli stdout get the error string:

[FACTRHS1] Template be-contact-model.riskLevel does not exist for assert. Function load-facts encountered an error

EnvLoadFactsFromString函数的事实参数如下:

The facts parameter of the EnvLoadFactsFromString function as following:

(appId "TEST") (be-contact-model.riskLevel "PASS") (be-contact-model.score 0) (channel "POST_TEXT.RlokQwRlVjUrTUlkIqOg.COMMENT") (constantKey "constantKey") (contact.model "contact_detector(GO)") (contact.nicknameResult.has_contact FALSE) (contact.nicknameResult.has_qq FALSE) (contact.nicknameResult.has_tel FALSE) (contact.nicknameResult.has_url FALSE) (contact.nicknameResult.has_wechat FALSE) (contact.riskLevel "PASS") (contact.score 0) (contact.textResult.baidusearch.REJECT_LEVEL 0) (contact.textResult.has_contact FALSE) (contact.textResult.has_qq FALSE) (contact.textResult.has_tel FALSE) (contact.textResult.has_url FALSE) (contact.textResult.has_wechat FALSE)

推荐答案

一旦加载二进制映像,就无法创建任何新构造.有序的事实和模式(没有对应的deftemplate构造的事实和模式)会自动创建一个deftemplate.如果您的规则尚未创建此自动deftemplate,则在加载二进制图像后将无法创建它:

Once you load a binary image, you can't create any new constructs. Ordered facts and patterns (those that don't have a corresponding deftemplate construct) automatically create a deftemplate. If your rules haven't already created this automatic deftemplate, it can't be created after you've already loaded a binary image:

CLIPS (6.31 6/12/19) CLIPS> (bsave example.bin) TRUE CLIPS> (bload example.bin) TRUE CLIPS> (assert (be-contact-model.riskLevel "PASS")) [FACTRHS1] Template be-contact-model.riskLevel does not exist for assert. CLIPS>

如果您的规则与已排序的事实相匹配,则可以在加载二进制映像后断言这种类型的事实.

If you have a rule that matches the ordered fact, you can assert this type of fact after you've loaded the binary image.

CLIPS> (clear) CLIPS> (defrule r1 (be-contact-model.riskLevel ?) =>) CLIPS> (bsave example.bin) TRUE CLIPS> (clear) CLIPS> (bload example.bin) TRUE CLIPS> (assert (be-contact-model.riskLevel "PASS")) <Fact-0> CLIPS>

因此,您收到一条错误消息的事实表明您正在试图断言任何规则都无法匹配的事实.

So the fact that you're getting an error message would indicate that you're attempting to assert a fact that none of your rules can match.

看来您的事实是属性/值对,因此,如果您断言没有规则可以匹配的事实,您可以做的一件事就是创建一个通用的deftemplate来表示所有这些特征:

It looks like your facts are attribute/value pairs, so one thing you can do if you're asserting facts that no rule can match is to create a generic deftemplate for representing all of them:

CLIPS> (clear) CLIPS> (deftemplate av (slot a) (slot v)) CLIPS> (assert (av (a be-contact-model.riskLevel) (v "PASS"))) <Fact-1> CLIPS>

更多推荐

CLIPS错误:断言模板xxx不存在

本文发布于:2023-10-20 09:08:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1510539.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不存在   断言   模板   错误   CLIPS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!