Rana
Rana

Reputation: 1

find relation in CLIPS expert systems

How can I find the relation between two or more family members in a family tree using CLIPS. I tried this rule but it's not working. I have a syntax Error.

Is there any hints to avoid the Error.

(defrule Family
     (FamilyTree ?L-name ?F-name)
      =>
      (assert(FamilyTree ?L-name ?F-name(read))
      (printout t ?L-name "is parent of" ?F-name crlf)))

Upvotes: 0

Views: 842

Answers (1)

Gary Riley
Gary Riley

Reputation: 10757

There appears to be some critical information missing from your question. The code snippet you posted loads correctly. It's only when I add a FamilyTree deftemplate that I get the error you described. If you use deftemplate facts in your rules, you have to use the syntax for deftemplate facts which requires specifying the slot name.

CLIPS> (clear)
CLIPS> 
(defrule Family
   (FamilyTree ?L-name ?F-name)
   =>
   (assert(FamilyTree ?L-name ?F-name(read))
   (printout t ?L-name "is parent of" ?F-name crlf)))
CLIPS> (clear)
CLIPS> (deftemplate FamilyTree (slot last-name) (slot first-name))
CLIPS> 
(defrule Family
   (FamilyTree ?L-name ?F-name)
   =>
   (assert(FamilyTree ?L-name ?F-name(read))
   (printout t ?L-name "is parent of" ?F-name crlf)))

[PRNTUTIL2] Syntax Error:  Check appropriate syntax for deftemplate patterns.

ERROR:
(defrule MAIN::Family
   (FamilyTree ?L-name
CLIPS> 

Upvotes: 0

Related Questions