clips - 剪辑:匹配(或不匹配空字符串)
问题描述
我正在尝试逐段翻译字符串,所以我知道原始字符串何时为空,然后我们就完成了。问题是,当“输入”字符串中没有任何内容时,CLIPS 怎么知道?
(defrule check-if-empty
?phase <- (phase CONVERT)
(input "code here possibly")
=>
(retract ?phase ?input)
(assert (phase PRINT))
(return))
解决方案
CLIPS 中的空字符串是“”,所以只需将“code here possible”替换为“”。除非您正在使用模块并希望在当前焦点的模块中结束规则的执行,否则也无需在规则的末尾放置 return。
(defrule check-if-empty
?phase <- (phase CONVERT)
?input <- (input "")
=>
(retract ?phase ?input)
(assert (phase PRINT)))
推荐阅读
- node.js - Node Sass 还不支持你当前的环境:Linux Unsupported architecture (arm) with Node.js 8.x
- promise - Promise 不等待 FTP 流上的解析
- r - 如何在符合 SAS 的 R 中运行混合效应逻辑纵向模型?
- python - 无法登录 Heroku 部署的应用程序,但可以在本地登录
- vba - 将工作表 1 A 列中的值匹配到工作表 2 A 列,如果未找到 A 值,则删除该行
- vba - 设置打印 VBA 的列宽
- r - 在神经网络 mlp r 上使用 wheights
- .htaccess - mod_rewrite 正在影响 $_GET
- excel - 刷新 Excel 表格过滤器和使用 VBA 排序时出错
- android - 是否可以将应用程序从 Playstore 中删除,但稍后恢复?