首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将已读列表拆分为其元素

将已读列表拆分为其元素
EN

Stack Overflow用户
提问于 2017-09-24 17:47:01
回答 1查看 178关注 0票数 0

我想让一个人有过敏症,然后把过敏症按过敏症分成不同的过敏症,以确定每个过敏症。为此,我使用了do-backward-chainingassert-stringreadline

代码语言:javascript
复制
(do-backward-chaining allergies)

(defrule ask-allergies
    (need-allergies nil)
    =>
    (printout t "Tell me your allergies (tomato, cheese): ")
    (assert-string (str-cat "(allergies " (readline) ")")))

(defrule assert-allergies
    (allergies $? ?a $?)
    =>
    (assert (allergy ?a)))

(reset)
(run)

但输出此错误:

代码语言:javascript
复制
Jess reported an error in routine Context.getVariable
    while executing (reset).
Message: No such variable _blank_mf1.
EN

回答 1

Stack Overflow用户

发布于 2018-03-01 12:53:21

我找不到任何关于反向链接如何工作的详细文档,但我认为您需要在只有$的地方使用$?variables?在断言-过敏性模式中:

代码语言:javascript
复制
Jess> (do-backward-chaining allergies)
TRUE
Jess> 
(defrule ask-allergies
    (need-allergies $?)
    =>
    (printout t "Tell me your allergies (tomato, cheese): ")
    (assert-string (str-cat "(allergies " (readline) ")")))
TRUE
Jess> 
(defrule assert-allergies
    (allergies $?b ?a $?e)
    =>
    (assert (allergy ?a)))
TRUE
Jess> (reset)
TRUE
Jess> (run)
Tell me your allergies (tomato, cheese): fish onions salt
4
Jess> (facts)
f-0   (MAIN::initial-fact)
f-1   (MAIN::need-allergies nil nil nil)
f-2   (MAIN::allergies fish onions salt)
f-3   (MAIN::allergy salt)
f-4   (MAIN::allergy fish)
f-5   (MAIN::allergy onions)
For a total of 6 facts in module MAIN.
Jess> 
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46388708

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档