Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 04-21-2003, 08:26 PM   #1 (permalink)
saline
I am red.
 
saline's Avatar
 
Join Date: Feb 2003
Location: Cleveland, OH
Posts: 139
saline is on a distinguished road
Don't call it a comeback...

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!
__________________
http://home.cwru.edu/~cak19

It's my homepage with odd little bits of javascript.
saline is offline   Reply With Quote
Old 04-22-2003, 03:38 PM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,489
sde is on a distinguished road
ai has always fascinated me . . this is a brilliant teaser .. nice work saline!

wish i had a better grasp on the english language .. i'd give this one a try.

i was thinking about how to recognize such a large amount of words .. and be able to respond appropriately .. it seems like a good way to make something like this work well is make a database of words, .. and label them for what they are .. such as verb, adjetive, noun, etc .... i was going to say more, but beyond that it is speculation .. i'd have to think some more.


thanks!
__________________
Mike
sde is offline   Reply With Quote
Old 04-22-2003, 07:41 PM   #3 (permalink)
alpha
Regular Contributor
 
Join Date: Feb 2003
Posts: 120
alpha is on a distinguished road
Send a message via AIM to alpha
I'll have to think about this. I'll attempt it if I have time.
alpha is offline   Reply With Quote
Old 04-22-2003, 07:50 PM   #4 (permalink)
saline
I am red.
 
saline's Avatar
 
Join Date: Feb 2003
Location: Cleveland, OH
Posts: 139
saline is on a distinguished road
It's definately a fun one. Getting it "working" is interesting because you're never really done as you can always keep adding things. Not to be discouraging to anyone who thinks about trying, you can always call yourself finished whenever you're satisfied.
__________________
http://home.cwru.edu/~cak19

It's my homepage with odd little bits of javascript.
saline is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Emailing and DB call rdove PHP 4 08-18-2004 04:31 PM
make a call using J2me tayyaba_rashid Java 2 07-27-2004 06:55 AM
J2ME Library call ballina Java 1 07-21-2004 07:38 AM
Program is skipping cin.getline call rarmknecht Standard C, C++ 3 05-15-2004 08:11 AM


All times are GMT -8. The time now is 10:45 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting