Friday, February 10, 2017

The 'Doctor' rule-set for Eliza

#|  These are the rules which drive the 'Doctor' version of Eliza. For the Eliza code, see here.

This entire post should be executable if copied and pasted into Common Lisp.

For an example of the rules in use, see here.  
|#
;;; Eliza Rules:  February 7th 2017 - Feb 10th 2017
;;;
;;;  From Peter Norvig's book: Chapter 5
;;; "Paradigms of Artificial Intelligence Programming"
;;;
;;; Pattern matching, patterns and dialogue manager
;;;
;;; Posted: http://interweave-consulting.blogspot.co.uk/2017/02/the-doctor-rule-set-for-eliza.html
;;;
;;;  Reminder: (how to load and access files)
;;;
; (load  "C:\\Users\\HP Owner\\Google Drive\\Lisp\\Prog-Eliza\\Eliza-Rules.lisp")

;;; --- SHORT LIST OF ELIZA RULES ---
;;;
;;;  Note that the symbol $name$ will be substituted by the user's first name
;;;  in the Eliza top-level procedure.

(defparameter +eliza-rules+
  '(
    (((?* ?x) hello (?* ?y))
     (Hi $name$ - please state your problem))

    (((?* ?x) I want (?* ?y))
     (What would it mean if you got ?y)
     (Why do you want ?y)
     (Suppose you got ?y soon))

    (((?* ?x) if (?* ?y))
     (Do you really think its likely that ?y $name$)
     (Do you wish that ?y)
     (What do you think about ?y)
     (Really - if ?y))

    (((?* ?x) no (?* ?y))
     (Why not?)
     ($name$ - you are being a bit negative)
     (Are you saying "NO" just to be negative?))

    (((?* ?x) I was (?* ?y))
     (Were you really?)
     (Perhaps I already knew you were ?y)
     (Why do you tell me you were ?y now?))

    (((?* ?x) I feel (?* ?y))
     (Do you often feel ?y ?))

    (((?* ?x) I felt (?* ?y))
     (What other feelings do you have?))))

;;; --- EXTENDED RULES (c. ~50)  ---

(defparameter +eliza-rules-extended+
'(
(((?* ?x) hello (?* ?y))
 (Hi $name$ - please state your problem.))

(((?* ?x) hi (?* ?y))
 (Hi $name$ - please state your problem.))

(((?* ?x) computer (?* ?y))
 (Do computers worry you?)
 (What do you think about machines?)
 (Why do you mention computers?)
 (What do you think machines have to do with your problem?))

(((?* ?x)  my name (?* ?y))
 ($name$ - I am smarter than you think!))

(((?* ?x) your name (?* ?y))
 (I prefer to be an anonymous doctor $name$))

(((?* ?x) sorry (?* ?y))
 (Please don't apologize)
 (Apologies are not necessary)
 (What feelings do you have when you apologize?))

(((?* ?x) I remember (?* ?y))
 (Do you often think of ?y)
 (Does thinking of ?y bring anything else to mind?)
 (What else do you remember?)
 (Why do you recall ?y  right now?)
 (What in the present situation reminds you of ?y)
 (What is the connection between me and ?y))

(((?* ?x) do you remember (?* ?y))
 (Did you think I would forget ?y ?)
 (Why do you think I should recall ?y now)
 (What about ?y)
 (You mentioned ?y))

(((?* ?x) if (?* ?y))
 (Do you really think its likely that ?y)
 (Do you wish that ?y)
 (What do you think about ?y)
 (Really -- if ?y))

(((?* ?x) I dreamt (?* ?y))
 (Really - ?y)
 (Have you ever fantasized ?y while you were awake?)
 (Have you dreamt ?y before?))

(((?* ?x) I dreamed (?* ?y))
 (Really - ?y)
 (Have you ever fantasized ?y while you were awake?)
 (Have you dreamed ?y before?))

(((?* ?x) dream about (?* ?y))
 (How do you feel about ?y in reality?))

(((?* ?x) dream (?* ?y))
 (What does this dream suggest to you?)
 (Do you dream often?)
 (What persons appear in your dreams?)
 (Dont you believe that dream has to do with your problem?))

(((?* ?x) my mother (?* ?y))
 (Who else in your family ?y)
 (Tell me more about your family))

(((?* ?x) my father (?* ?y))
 (Your father?)
 (Does he influence you strongly?)
 (What else comes to mind when you think of your father?))

(((?* ?x) I want (?* ?y))
 (What would it mean to you if you got ?y)
 (Why do you want ?y)
 (Suppose you got ?y soon))

(((?* ?x) I am glad (?* ?y))
 (How have I helped you to be ?y)
 (What makes you happy just now)
 (Can you explain why you are happy that ?y))

(((?* ?x) I am sad (?* ?y))
 (I am sorry to hear you are depressed)
 (I'm sure its not pleasant to be sad))

(((?* ?x) are like (?* ?y))
 (What resemblance do you see between ?x and ?y ?))

(((?* ?x) is like (?* ?y))
 (In what way  is  it that ?x is like ?y)
 (What resemblance do you see?)
 (Could there really be some connection?)
 (How?))

(((?* ?x) alike (?* ?y))
 (In what way?)
 (What similarities are there?))

(((?* ?x) same (?* ?y))
 (What other connections do you see?))

(((?* ?x) I was (?* ?y))
 (Were you really?)
 (Perhaps I already knew you were ?y)
 (Do you think its relevant that you were ?y now?))

(((?* ?x) was I (?* ?y))
 (What if you were ?y ?)
 (Do you think you were ?y)
 (What would it mean if you were ?y))

(((?* ?x) I am (?* ?y))
 (In what way are you ?y)
 (Do you want to be ?y ?))

(((?* ?x) am I (?* ?y))
 (Do you believe you are ?y)
 (Would you want to be ?y)
 (You wish I would confirm you are ?y)
 (What would it mean if you were ?y))

(((?* ?x) am (?* ?y))
(Why do you say "AM?")
 (I dont really get that) )

(((?* ?x) are you (?* ?y))
 (Why are you interested in whether I am ?y or not?)
 (Would you prefer if I werent ?y)
 (Perhaps I am ?y in one of your fantasies?))

(((?* ?x) you are (?* ?y) )
 (Perhaps I am ?y only in your imagination!)
 (What makes you think I am ?y ?))

(((?* ?x) because (?* ?y))
 (Is ?y the real reason?)
 (What other reasons might there be?)
 (Does ?y seem to explain anything else?))

(((?* ?x) were you (?* ?y))
 (Perhaps I was ?y)
 (What do you think?)
 (In some places being ?y is barely legal!)
 (What if I had been ?y))

(((?* ?x) I cant (?* ?y))
 (Maybe you could ?y now)
 (What if you could ?y ?))

(((?* ?x) I miss (?* ?y))
 (Has ?y been gone long?)
 ($name$ - I can feel your sadness about ?y) )

(((?* ?x) I feel (?* ?y))
 (Do you often feel ?y ?))

(((?* ?x) I felt (?* ?y))
 (What other feelings do you have?))

(((?* ?x) I (?* ?y) you (?* ?z))
 (Perhaps in your fantasy we ?y each other))

(((?* ?x) why dont you (?* ?y))
 (Should you ?y yourself?)
 (Do you believe I dont ?y)
 (Perhaps I will ?y in good time))

(((?* ?x) yes (?* ?y))
 (You seem quite positive - please expand on this)
 ($name$ - I feel we should move on from this to another subject)
 (I understand $name$ but you need to move on to a new topic))

(((?* ?x) no (?* ?y))
 (Why not $name$ ?)
 (You are being a bit negative $name$)
 (Are you saying "NO" just to be negative?))

(((?* ?x) someone (?* ?y))
 (Can you be more specific about - ?y))

(((?* ?x) everyone (?* ?y))
 (Surely not everyone ?y)
 (Can you think of anyone in particular who ?y)
 (Who for example?)
 (You are thinking of a special person?))

(((?* ?x) always (?* ?y))
 (Can you think of a specific example?)
 (When?)
 (What incident are you thinking of?)
 (Really  - always?))

(((?* ?x) what (?* ?y))
 (Why do you ask?)
 (Does that question interest you?)
 (What is it you really want to know?)
 (What do you think?)
 (What comes to your mind when you ask that?))

(((?* ?x) why (?* ?y))
 (Its a good question - why ?y)
 (?x many things but its never that clear)
 (Well $name$ you are really in to deep questions) )

(((?* ?x) perhaps (?* ?y))
 (You do not seem quite certain.))

(((?* ?x) are (?* ?y))
 (Did you think they might not be ?y)
 (Possibly they are ?y))

(((?* ?x) that I (?* ?y))
 (Are you happy or sad that you ?y)
 (Possibly you should ?y))

(((?* ?x))
 (Very interesting)
 (I am not sure I understand you fully)
 (What does that suggest to you?)
 (Please continue)
 (Go on)
 (Do you feel strongly about discussing such things?))
))

No comments:

Post a Comment

Comments are moderated. Keep it polite and no gratuitous links to your business website - we're not a billboard here.