2016-08-30 39 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")))