剪辑范围在 2 json 个输入之间查找
Clips range find between 2 json inputs
我想执行一个规则;
假设我有一个 input.json 它包含一个名称值 pair.Example;
{
“质量”:“300”
}
我还有一个常量json,例子
[{
“向上”:“100”,
“向下”:“0”,
“数据”:“xx”
},
{
“向上”:“200”,
“向下”:“100”,
“数据”:“yy”
},
,
{
“向上”:“300”,
“向下”:“200”,
“数据”:“zz”
}
]
我正在尝试查找上下范围内的数据的属性值。
对于这个 ı,必须得到 zz 因为 "quality":"300" 在 200-300 之间。
我怎样才能在剪辑规则中成功。
CLIPS (6.31 6/12/19)
CLIPS>
(deftemplate pair
(slot name)
(slot value))
CLIPS>
(deffacts pairs
(pair (name "quality") (value 300)))
CLIPS>
(deftemplate data
(slot name)
(slot up)
(slot down))
CLIPS>
(deffacts data-values
(data (name "xx") (up 100) (down 0))
(data (name "yy") (up 200) (down 100))
(data (name "zz") (up 300) (down 200)))
CLIPS>
(defrule in-range
(pair (name "quality")
(value ?value))
(data (name ?name)
(up ?up)
(down ?down))
(test (and (> ?value ?down) (<= ?value ?up)))
=>
(printout t ?name " is in range." crlf))
CLIPS> (reset)
CLIPS> (facts)
f-0 (initial-fact)
f-1 (pair (name "quality") (value 300))
f-2 (data (name "xx") (up 100) (down 0))
f-3 (data (name "yy") (up 200) (down 100))
f-4 (data (name "zz") (up 300) (down 200))
For a total of 5 facts.
CLIPS> (agenda)
0 in-range: f-1,f-4
For a total of 1 activation.
CLIPS> (run)
zz is in range.
CLIPS>
我想执行一个规则;
假设我有一个 input.json 它包含一个名称值 pair.Example; { “质量”:“300” }
我还有一个常量json,例子 [{ “向上”:“100”, “向下”:“0”, “数据”:“xx” }, { “向上”:“200”, “向下”:“100”, “数据”:“yy” }, , { “向上”:“300”, “向下”:“200”, “数据”:“zz” } ]
我正在尝试查找上下范围内的数据的属性值。 对于这个 ı,必须得到 zz 因为 "quality":"300" 在 200-300 之间。
我怎样才能在剪辑规则中成功。
CLIPS (6.31 6/12/19)
CLIPS>
(deftemplate pair
(slot name)
(slot value))
CLIPS>
(deffacts pairs
(pair (name "quality") (value 300)))
CLIPS>
(deftemplate data
(slot name)
(slot up)
(slot down))
CLIPS>
(deffacts data-values
(data (name "xx") (up 100) (down 0))
(data (name "yy") (up 200) (down 100))
(data (name "zz") (up 300) (down 200)))
CLIPS>
(defrule in-range
(pair (name "quality")
(value ?value))
(data (name ?name)
(up ?up)
(down ?down))
(test (and (> ?value ?down) (<= ?value ?up)))
=>
(printout t ?name " is in range." crlf))
CLIPS> (reset)
CLIPS> (facts)
f-0 (initial-fact)
f-1 (pair (name "quality") (value 300))
f-2 (data (name "xx") (up 100) (down 0))
f-3 (data (name "yy") (up 200) (down 100))
f-4 (data (name "zz") (up 300) (down 200))
For a total of 5 facts.
CLIPS> (agenda)
0 in-range: f-1,f-4
For a total of 1 activation.
CLIPS> (run)
zz is in range.
CLIPS>