CLIPS LHS 匹配多时隙
CLIPS LHS match multislot
我为专家系统写了这条规则:
(defrule wild chicory
(attribute (name habitat) (value sea montain grassland unknown))
=>
(assert (plant "Cichorium_Intybus"))
)
但是我不希望栖息地的值与我给出的所有值相匹配,而是只与至少一个值相匹配。
我想知道我应该怎么做。我可以这样做:
(defrule wild chicory
(or (attribute (name habitat) (value sea))
(attribute (name habitat) (value mountain))
(attribute (name habitat) (value grassland))
(attribute (name habitat) (value unknow))
)
=>
(assert (plant "Cichorium_Intybus"))
)
但是我想知道有没有更好的解决办法。谢谢
如果值是单个字段槽,请这样做:
(defrule wild chicory
(attribute (name habitat) (value sea | mountain | grassland | unknown))
=>
(assert (plant "Cichorium_Intybus")))
如果值是一个多字段槽,这样做:
(defrule wild chicory
(attribute (name habitat) (value $? sea | mountain | grassland | unknown $?))
=>
(assert (plant "Cichorium_Intybus")))
我为专家系统写了这条规则:
(defrule wild chicory
(attribute (name habitat) (value sea montain grassland unknown))
=>
(assert (plant "Cichorium_Intybus"))
)
但是我不希望栖息地的值与我给出的所有值相匹配,而是只与至少一个值相匹配。 我想知道我应该怎么做。我可以这样做:
(defrule wild chicory
(or (attribute (name habitat) (value sea))
(attribute (name habitat) (value mountain))
(attribute (name habitat) (value grassland))
(attribute (name habitat) (value unknow))
)
=>
(assert (plant "Cichorium_Intybus"))
)
但是我想知道有没有更好的解决办法。谢谢
如果值是单个字段槽,请这样做:
(defrule wild chicory
(attribute (name habitat) (value sea | mountain | grassland | unknown))
=>
(assert (plant "Cichorium_Intybus")))
如果值是一个多字段槽,这样做:
(defrule wild chicory
(attribute (name habitat) (value $? sea | mountain | grassland | unknown $?))
=>
(assert (plant "Cichorium_Intybus")))