我为专家系统编写了这条规则:
(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"))
)
但是我想知道是否有更好的解决方案。谢谢
最佳答案
如果 value 是单个字段槽,请这样做:
(defrule wild chicory
(attribute (name habitat) (value sea | mountain | grassland | unknown))
=>
(assert (plant "Cichorium_Intybus")))
如果 value 是多字段槽,请这样做:
(defrule wild chicory
(attribute (name habitat) (value $? sea | mountain | grassland | unknown $?))
=>
(assert (plant "Cichorium_Intybus")))
关于CLIPS LHS 匹配多槽,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39237501/