【问题标题】:CLIPS find-all-facts return valueCLIPS find-all-facts 返回值
【发布时间】:2017-03-22 08:26:46
【问题描述】:

我通过使用 CLIPSJNI 改编 WineDemo.clp 示例进行了尝试。

(defmodule SEVERITY (import MAIN ?ALL)
                (export deffunction get-dengue-list))

(deffacts any-attributes
          (attribute (name clinical-prediction) (value any))
          (attribute (name lab-prediction) (value any)))

(deftemplate SEVERITY::dengue
      (slot name (default ?NONE))
      (multislot clinical (default any))
      (multislot lab (default any)))

(deffacts SEVERITY::the-dengue-list
     (dengue (name "DF") (clinical dengue-f) (lab positive))
     (dengue (name "DHF") (clinical dengue-hf) (lab positive))
     (dengue (name "DSS") (clinical dengue-ss) (lab positive)))

(defrule SEVERITY::generate-severity
   (dengue (name ?name)
      (clinical $? ?c $?)
      (lab $? ?l $?))
   (attribute (name clinical-prediction) (value ?c) (certainty ?certainty-1))
   (attribute (name lab-prediction) (value ?l) (certainty ?certainty-2))
     =>
    (assert (attribute (name dengue) (value ?name)
                 (certainty (min ?certainty-1 ?certainty-2)))))

(deffunction SEVERITY::dengue-sort (?w1 ?w2)
   (< (fact-slot-value ?w1 certainty)
      (fact-slot-value ?w2 certainty)))

(deffunction SEVERITY::get-dengue-list ()
  (bind ?facts (find-all-facts ((?f attribute))
                           (and (eq ?f:name dengue) (>= ?f:certainty 20))))
  (sort dengue-sort ?facts))

但是,当我尝试用 Java 将其打印出来时,我无法返回任何事实,如下所示。

String evalStr = "(SEVERITY::get-dengue-list)";
MultifieldValue pv = (MultifieldValue)clips.eval(evalStr);
System.out.println(pv);

The list I got when I use this:

(find-all-facts ((?f attribute)) TRUE)

我似乎无法从登革热列表中获得详细信息。我不希望显示所有属性。 我对此还是很陌生,我被困住了。谁能帮帮我吗?

谢谢!

【问题讨论】:

    标签: java clips expert-system


    【解决方案1】:

    generate-severity 规则永远不会执行,因此永远不会生成名为 dengue 的属性事实,get-dengue-list 函数将返回一个空列表。为了执行规则,必须有与登革热事实中的实验室和临床槽值相匹配的临床预测和实验室预测属性。 “阳性”的实验室值与“任何”的临床预测值不匹配。 “dengue-f”、“dengue-hf”和“dengue-ss”的临床值与“any”的实验室预测值不匹配。

    如果您希望符号 'any' 在匹配时具有特殊意义,则需要调整您在模式中使用的约束。例如:

       (attribute (name clinical-prediction) (value ?c | any) (certainty ?certainty-1))
       (attribute (name lab-prediction) (value ?l | any) (certainty ?certainty-2))
    

    您可能遇到的另一个问题是,您使用的查询只会返回确定性至少为 20 的登革热属性事实。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-16
      • 1970-01-01
      • 2013-03-31
      • 2014-01-24
      • 1970-01-01
      • 1970-01-01
      • 2020-10-18
      相关资源
      最近更新 更多