2016-08-30 35 views
1

我写了这个规则的专家系统:CLIPS LHS匹配的多时隙

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

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

回答

0

如果值是单场插槽,这样来做:

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