Clips 检查 defrule 的适当语法

我在尝试制作一个程序,询问申请人是否无家可归、失业、无存款等,并获得一级或二级福利支持作为答案,但我在 Clips 中无法加载这个程序。我收到了下面的错误信息

代码

(defrule Claimant(Claimant-is homeless)(Claimant-is unemployed)(Claimant-is nosavings)(Claimant-is dependants)(Claimant-is disabled))(deftemplate Benefit   (slot benefit))(defrule Level1   Claimant(homesless yes) (unemployed yes) (nosavings no) (dependants yes) (disabled yes))   =>   (assert (Benefit (benefit level1)))   (printout t "You get level 1 benefit support" crlf))(defrule Level2   Claimant(homesless yes) (unemployed yes) (nosavings no) (dependants no) (disabled no))   =>   (assert (Benefit (benefit level2)))   (printout t "You get level 2 benefit support" crlf))

错误

Defining defrule: Claimant [PRNTUTIL2] Syntax Error:  Check appropriate syntax for defrule.ERROR:(defrule MAIN::Claimant   (Claimant-is homeless)   (Claimant-is unemployed)   (Claimant-is nosavings)   (Claimant-is dependants)   (Claimant-is disabled)   )Defining deftemplate: BenefitDefining defrule: Level1 [PRNTUTIL2] Syntax Error:  Check appropriate syntax for defrule.ERROR:(defrule MAIN::Level1   ClaimantDefining defrule: Level2 [PRNTUTIL2] Syntax Error:  Check appropriate syntax for defrule.ERROR:(defrule MAIN::Level2   ClaimantFALSECLIPS> 

回答:

您的语法存在几个需要纠正的问题。

设计也可以简化(但我不会讨论这方面)。

以下展示了一个经过修正的等效版本。

homeless.clp

(deftemplate Claimant  (slot homeless (type SYMBOL) (allowed-values yes no))  (slot unemployed (type SYMBOL) (allowed-values yes no))  (slot nosavings (type SYMBOL) (allowed-values yes no))  (slot dependants (type SYMBOL) (allowed-values yes no))  (slot disabled (type SYMBOL) (allowed-values yes no)))(deftemplate Benefit   (slot benefit (type SYMBOL) (allowed-values level1 level2)))(defrule Level1   (Claimant (homeless yes) (unemployed yes) (nosavings no)             (dependants yes) (disabled yes))   =>   (assert (Benefit (benefit level1)))   (printout t "You get level 1 benefit support" crlf))(defrule Level2   (Claimant (homeless yes) (unemployed yes) (nosavings no)             (dependants no) (disabled no))   =>   (assert (Benefit (benefit level2)))   (printout t "You get level 2 benefit support" crlf))

现在您可以使用以下命令进行测试

(clear)(load "homeless.clp")(assert (Claimant (homeless yes) (unemployed yes) (nosavings no) (dependants no) (disabled no)))(run) 

并得到

You get level 2 benefit support

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注