clips - 如何添加全局变量来计算是或否响应的数量?
问题描述
我正在开发一个营养诊断系统,在该系统中向用户询问问题/症状,他们通过输入是或否来回答。我想跟踪是或否的计数并用它们进行计算。就像将是或否的计数存储在全局变量中一样。我已经有一个计算功能,但不确定如何从用户输入中捕获是或否。我是使用 Jess 规则的新手。下面我添加了工作规则的代码。
(defrule menu::initialize
(diagnosis)
=>
(assert
(question (ident q21) (text "Does the child's hair tend to be slight? (Yes or No)") (type yes-no))
(question (ident q22) (text "Does the child's hair tend to be reddish? (Yes or No)") (type yes-no))
(question (ident q23) (text "Is the child often affected by ISPA/ TBC? (Yes or No)") (type yes-no))
(question (ident q24) (text "Does the child's hair tend to be easily falls off? (Yes or No)") (type yes-no))
(question (ident q25) (text "Is there any abnormality on the child's complexion? (Yes or No)") (type yes-no))
(question (ident q26) (text "Is there any swelling on the child's face? (Yes or No)") (type yes-no))
)
(menu::init)
)
解决方案
您已经展示了一个名为“menu::initialize”的规则,它插入了一些称为“问题”的事实。您需要一个规则来触发这些事实,然后该规则将包含一个将 1 添加到全局变量的语句。您可以在 Jess 手册中找到有关规则和使用全局变量的示例。
请不要指望 SO 上的某个人会为您做作业。
推荐阅读
- mongodb - $in 当数组为空时不返回任何内容
- php - Laravel - MacOS - 失败。退出代码:127(找不到命令)工作目录
- python - 如何为 ML 模型正确设置种子值?
- swift - 为什么推送到 ViewController 会将其显示为弹出窗口?
- server - Magento 1.9 - 如何解决 GoDaddy 主机超时错误?
- android - 在 Android 9 中使用 Apache HTTP
- python - 使用 loc 对 Pandas DataFrame 进行选择性操作而不覆盖未选择的行
- nginx - Nginx 到不同位置的特定路径
- c# - C# + MySQL - 已经有一个打开的 DataReader 与此连接关联
- tensorflow - 如何在 Tensorflow 的 LSTM 网络中将梯度反向传播到时间步长 1 的输入上?