I think that Mark Rudolph wrote:
>> Why can't the assigned variable be used?, and in what
>> sense is ?role-id 'unbound?'


Hi Mark,
Though your code doesn't show it, I assume that you are calling (reset)
somewhere in your script.  If not, you need to call (reset) before (run) in
order for Jess to operate properly.  Also, it seems that you have some
redundancy in your LHS patterns, especially with the (test) conditions.

Try this code and tell me if it's what you want:
;; =========================
;; speech.clp
(clear)
(watch all)

;; Define your facts
(deftemplate speech (multislot text))
(deftemplate role (slot name))

;; Define your rule
(defrule R2
  ; Notice the change in the patterns
  ?unreduced <-(speech (text ?x IS ANGRY))
  (role (name ?name&:(eq ?name ?x)))
=>
  (assert (speech (text YOU ARE ANGRY)))
  (retract ?unreduced))

;; Reset working memory
(reset)

;; Assert your facts and bind variables --
;; I'm only binding ?role-id in case you want to use it later,
;; else it serves no purpose now with the pattern change.
(bind ?role-id (assert (role (name HAMLET))))
(assert (speech (text HAMLET IS ANGRY)))

;; Run your program
(run)
;; =========================

Jess will print out:
Jess> (batch speech.clp)
MAIN::R2: +1+1+1+1+1+1+2+t
 ==> Focus MAIN
 ==> f-0 (MAIN::initial-fact)
 ==> f-1 (MAIN::role (name HAMLET))
 ==> f-2 (MAIN::speech (text HAMLET IS ANGRY))
==> Activation: MAIN::R2 :  f-2, f-1
FIRE 1 MAIN::R2 f-2, f-1
 ==> f-3 (MAIN::speech (text YOU ARE ANGRY))
 <== f-2 (MAIN::speech (text HAMLET IS ANGRY))
 <== Focus MAIN

Cheers,
Jason Morris
Assistant Jess Listserver Moderator
-------------------------------------

Jason Morris
Morris Technical Solutions
[EMAIL PROTECTED]
www.morristechnicalsolutions.com
fax/phone: 503.692.1088





--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------

Reply via email to