2015-01-13 2 views
1

청구인 노숙자, 실업자에게는 필요 없음 등을 묻는 프로그램을 만들려고 노력 중이며 답변으로 레벨 1 또는 2 혜택 지원을받을 수 있지만 클립으로로드 할 수 없습니다. . 나는클립 찌그러짐에 대한 적절한 구문 확인

코드

(defrule Claimant 
(Claimant-is homeless) 
(Claimant-is unemployed) 
(Claimant-is nosavings) 
(Claimant-is dependants) 
(Claimant-is disabled)) 

(deftemplate Benefit 
    (slot benefit)) 

(defrule Level1 
    Claimant(homesless yes) (unemployed yes) (nosavings no) (dependants yes) (disabled yes)) 
    => 
    (assert (Benefit (benefit level1))) 
    (printout t "You get level 1 benefit support" crlf)) 

(defrule Level2 
    Claimant(homesless yes) (unemployed yes) (nosavings no) (dependants no) (disabled no)) 
    => 
    (assert (Benefit (benefit level2))) 
    (printout t "You get level 2 benefit support" crlf)) 

오류

Defining defrule: Claimant 
[PRNTUTIL2] Syntax Error: Check appropriate syntax for defrule. 

ERROR: 
(defrule MAIN::Claimant 
    (Claimant-is homeless) 
    (Claimant-is unemployed) 
    (Claimant-is nosavings) 
    (Claimant-is dependants) 
    (Claimant-is disabled) 
    ) 
Defining deftemplate: Benefit 
Defining defrule: Level1 
[PRNTUTIL2] Syntax Error: Check appropriate syntax for defrule. 

ERROR: 
(defrule MAIN::Level1 
    Claimant 
Defining defrule: Level2 
[PRNTUTIL2] Syntax Error: Check appropriate syntax for defrule. 

ERROR: 
(defrule MAIN::Level2 
    Claimant 
FALSE 
CLIPS> 

답변

1

귀하의 구문을 수정해야합니다 몇 가지 문제를 가지고 아래의 오류가 발생합니다.

디자인을 단순화 할 수도 있습니다 (단,이 부분에 대해서는 언급하지 않겠습니다).

다음은 수정 된 동일한 버전입니다.

homeless.clp

(deftemplate Claimant 
    (slot homeless (type SYMBOL) (allowed-values yes no)) 
    (slot unemployed (type SYMBOL) (allowed-values yes no)) 
    (slot nosavings (type SYMBOL) (allowed-values yes no)) 
    (slot dependants (type SYMBOL) (allowed-values yes no)) 
    (slot disabled (type SYMBOL) (allowed-values yes no)) 
) 

(deftemplate Benefit 
    (slot benefit (type SYMBOL) (allowed-values level1 level2)) 
) 

(defrule Level1 
    (Claimant (homeless yes) (unemployed yes) (nosavings no) 
      (dependants yes) (disabled yes)) 
    => 
    (assert (Benefit (benefit level1))) 
    (printout t "You get level 1 benefit support" crlf) 
) 

(defrule Level2 
    (Claimant (homeless yes) (unemployed yes) (nosavings no) 
      (dependants no) (disabled no)) 
    => 
    (assert (Benefit (benefit level2))) 
    (printout t "You get level 2 benefit support" crlf) 
) 

이제

(clear) 

(load "homeless.clp") 

(assert (Claimant (homeless yes) (unemployed yes) (nosavings no) (dependants no) (disabled no))) 

(run) 

으로 테스트하고 그것은 작동

You get level 2 benefit support 
+0

감사 얻을 수 있습니다! – PommeFrite01