I never really left...
If you get that joke, thats cool, you remember the eighties, or you're a big LL Cool J fan or something. If not, thats cool too youngin'. So I was driving home yesterday and I was wondering what kind of project I was going to do for today. I was really racking my brain for what spiffy thing I could pull out as interesting or historical. Literally I was looking at houses I was driving by wondering how I could get people to code a chimney and make it interesting.
Then I remembered, I've been saving something cool for a while, sitting on it for just an occasion like this one (a desperate one).
Eliza.
Oh Eliza you crazy therapist script how I love you. Ok, as usual first were going to do a little history.
Eliza was written sometime during the 1960's (those crazy 60's people). It's a simple attempt at artificial intelligence. Eliza was made to emulate and or parody a "Rogerian psychotherapist". The style of Rogerian psychotherapy is (I presume) based upon keeping the patient talking about themself in order for the doctor to learn more about them and the patient to perhaps reveal hidden truths to themself. This involves the doctor constantly asking questions about every statement. Here's an example of how this therapy might work between a young woman and an average Rogerian Psychotherapist.
Code:
RG - Rogerian Psychotherapist
young woman: Men are all alike.
RG: In what way?
young woman: They're always bugging us about something specific or other.
RG: Can you think of a specific example?
young woman: Well, my boyfriend made me come here.
RG: Your boyfriend made you come here?
young woman: He says I'm depressed much of the time.
RG: I am sorry to hear you are depressed.
young woman: It's true. I'm unhappy.
RG: Do you think coming here will help you not to be unhappy?
young woman: I need some help, that much seems certain.
RG: What would it mean to you if you got some help?
young woman: Perhaps I could learn to get along with my mother.
RG: Tell me more about your family.
...
It can go on for hours because every statement by the young woman can pose another question for the therapist.
The interesting thing to notice with this section is in the third through the sixth question.
Code:
young woman: Well, my boyfriend made me come here.
RG: Your boyfriend made you come here?
young woman: He says I'm depressed much of the time.
RG: I am sorry to hear you are depressed.
young woman: It's true. I'm unhappy.
RG: Do you think coming here will help you not to be unhappy?
young woman: I need some help, that much seems certain.
RG: What would it mean to you if you got some help?
The very perceptive reader will notice that each question by the therapist contains the same subject as the womans statement before it boyfriend, depressed, unhappy they're repeated from statement to question to keep the conversation going.
Another interesting thing to note about this conversation is that the part of the therapist was produced entirely by the Eliza program. It wasen't an example I wrote but instead an actual snippet of a "conversation" between a young woman and Eliza, you can see more of it
here.
Ok, now onto how Eliza works.
When you "talk" to Eliza she actually has no idea what the conversation is about. She doesn't understand the subjects, all she knows is the common constructions of english sentences and exploits these constructions to produce what looks like a conversation.
Looking at the above sections again when the young woman says her boyfriend brought her Eliza picked up on the word "my".
input: Well, my boyfriend made me come here.
output Your boyfriend made you come here?
The output is just the input past the first my with the "my"s switched to "your"s and the "me"s to "you"s.
Next statement:
input: He says I'm depressed much of the time.
output: I am sorry to hear you are depressed.
What was the keyword here?
The keyword was I'm, it provides a description of the user so it can be further questioned.
This example is actually somewhat sophisticated because it
recognizes that "depressed" is a bad thing so Eliza expresses sympathy. A more general version can just simply ask the eternal question, why?
input: He says I'm depressed much of the time.
output: Why are you depressed?
input: I'm hot.
output: Why are you hot?
input: I'm tired.
output: Why are you tired?
input: I'm getting really frustrated at these responses.
output: Why are you getting really frustrated at these responses?
OK, so I think the project is kind of obvious by now. It's time for a little Eliza implementation, I've already provided you with a few symantic rules to resond to (I'm, my). The next important thing is the "catch all" phrase that Eliza responds with when she has no response.
For example:
"I'm confused can you explain that some more"
"hmmm, ok go on"
"Ok, I think I follow"
Things that can be said to just try and keep the conversation going in hopes that the user will say a keyword.
This has a bunch of conversations with an Eliza bot with people using AIM.
http://nasledov.com/misha/elizalog/
Here's a google search for Eliza Rogerian Psychotherapist:
http://www.google.com/search?hl=en&l...=Google+Search
The top link for the above Google searchh is a web based implementation of Eliza so you can see how it responds.
If you come up with any constructions in english that work please post them here so people can implement them as well. This program can be done in any language (that I can think of) with a fair bit of ease although it does require some string parsing skill.
'Til next time, whenever that may be, Good Luck!