1

我为专家系统编写了这条规则:

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

但我想知道是否有更好的解决方案。谢谢

4

1 回答 1

1

如果 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")))
于 2016-08-30T23:35:17.937 回答