【问题标题】:Split a read list into its elements将读取列表拆分为其元素
【发布时间】:2017-09-24 09:47:01
【问题描述】:

我想让一个人过敏,然后将过敏逐个过敏分开来断言每个人。为此,我使用do-backward-chainingassert-stringreadline

(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)

但是输出这个错误:

Jess reported an error in routine Context.getVariable
    while executing (reset).
Message: No such variable _blank_mf1.

【问题讨论】:

    标签: clips jess


    【解决方案1】:

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

    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> 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-30
      • 1970-01-01
      • 1970-01-01
      • 2018-07-14
      • 2015-05-19
      • 1970-01-01
      • 2017-04-25
      • 1970-01-01
      相关资源
      最近更新 更多