CLIPS错误:断言模板xxx不存在 [英] CLIPS Error:Template xxx does not exist for assert
问题描述
- 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不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!