header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

[August 25th, 2008] Check the home page regarding PowerShell related news from a brand new sponsor: Idera

The ELIZA Program - The PowerShell Rendition
Last Post 02 May 2008 03:09 PM by kscriss. 8 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
kscrissUser is Offline
Basic Member
Basic Member
Posts:119

--
16 Apr 2008 06:59 PM  

 

http://en.wikipedia.org/wiki/ELIZA  : ELIZA is a computer program by Joseph Weizenbaum, designed in 1966, which parodied a Rogerian therapist, largely by rephrasing many of the patient's statements as questions and posing them to the patient.

http://chayden.net/eliza/Eliza.html  :  A JAVA implementation by Charles Hayden, "This rendition of ELIZA is a complete and faithful implementation of the program described by Weizenbaum. The script language has been reformatted for clarity, but is unchanged in its content."  It includes a working ELIZA web site and his source code.  Give it a try!

I'm going to give it a try in PowerShell.  I'll appreciate your help when I get stuck.  The JAVA souce above is fairly clean and eazy to read even if your not really a JAVA programmer.  If anyone wants to break it down by function and take a chunk that would be kewl with me.  Dive in and divvy it up.

This will be fun. 

My blog: http://blogs.powershellcentral.com/kscriss/
halr9000User is Offline
PowerShell MVP, Site Admin
Basic Member
Basic Member
Posts:334
Avatar

--
16 Apr 2008 07:13 PM  
Oh, that should be cool! Keep us updated.
Community Director, PowerShellCommunity.org
Co-host, PowerScripting Podcast
Author, TechProsaic
RichSUser is Offline
New Member
New Member
Posts:41
Avatar

--
17 Apr 2008 11:53 AM  

Me too.  I remember playing with ELIZA way back.

Rather than leaving it to people to grab bits why not ask for people to do specific chunks to make sure everythings covered.   I'm up for a go at some of it

 

Richard Siddaway
Microsoft MVP - PowerShell
UK PowerShell User group Leader
www.get-psuguk.org.uk
kscrissUser is Offline
Basic Member
Basic Member
Posts:119

--
17 Apr 2008 03:16 PM  

Excellent. I'm trying to get Charles Hayden to blog about the algorithm inside this thread. I'm also trying to get his permission to print portions of his instructions.txt file located at http://chayden.net/eliza/instructions.txt  It does a pretty good job of explaining the input file which both Charles and Joseph Weizenbaum refer to as a script. The input file dictate or controls what Eliza's responses would be. Apparently the input file determines whether Eliza is sassy, or pehaps rude, and/or the classic Rogerian therapist.

Mr. Weizenbaum wrote a paper about Eliza and it is available at the following link. http://i5.nyu.edu/~mm64/x52.9265/january1966.html  

I think I'll study the algorithm for at least a week and then start with a mock up of a PowerShell Eliza.CSV input file using Charles' intructions.txt as my main reference. Then I'll use Joseph's explanation for my logic.

We can definetly divvy it up.

My blog: http://blogs.powershellcentral.com/kscriss/
halr9000User is Offline
PowerShell MVP, Site Admin
Basic Member
Basic Member
Posts:334
Avatar

--
17 Apr 2008 04:55 PM  
I've already finished my part:

function ReadScriptCsv ($scriptFile) { import-csv $scriptFile }

:D
Community Director, PowerShellCommunity.org
Co-host, PowerScripting Podcast
Author, TechProsaic
kscrissUser is Offline
Basic Member
Basic Member
Posts:119

--
22 Apr 2008 06:40 PM  

http://www.masswerk.at/elizabot/  
The above link is a very nice JAVA SCRIPT implementation by Norbert Landsteiner in 2005. It is a very concise two script rendition consisting of ELIZAbot.js and ELIZAdata.js. The logic is only 391 lines of code which I think is amazing. The data is 611 lines of code.

This project hasn't defeated me yet.  I'm just running behind on my initial study time estimates.

My blog: http://blogs.powershellcentral.com/kscriss/
kscrissUser is Offline
Basic Member
Basic Member
Posts:119

--
29 Apr 2008 08:43 PM  

Eureka! I'm starting to get the algorith now. I just had a moment of clarity which I'm highlighting in the following code-block below.

"Do you remember Monad?" -like "* you remember *"


^^^ That's all I need to know to get going. ^^^

Now I need help with my input file. I can't decide whether to do a .CSV file, or hard a code a multi dimensional hash/array table, or perhaps hard code some sort of PS object.

The following JavaScript code snippet is portion of the standard Eliza input file.

# ["remember", 5, [
#  ["* i remember *", [
#     "Do you often think of (2) ?",
#     "Does thinking of (2) bring anything else to mind ?",
#     "What else do you recollect ?",
#     "Why do you remember (2) just now ?",
#     "What in the present situation reminds you of (2) ?",
#     "What is the connection between me and (2) ?",
#     "What else does (2) remind you of ?"
#   ]],
#  ["* do you remember *", [
#     "Did you think I would forget (2) ?",
#     "Why do you think I should recall (2) now ?",
#     "What about (2) ?",
#     "goto what",
#     "You mentioned (2) ?"
#   ]],
#  ["* you remember *", [
#     "How could I forget (2) ?",
#     "What about (2) should I remember ?",
#     "goto you"
#   ]]
# ]]

There can be many keywords but for each keyword and its designated sorting-weight; there can be be multiple decomposition patterns and for any decomposition pattern there can be multiple reassembly patterns.

In the example above the keyword is "remember" its weight is 5, its decomposition patterns are the strings with the "*" wildcard characters in them and the reassembly patterns have the (2) numbers in them.

I need to sort the list of keywords by weight" and then find the decomposition pattern that matches the highest weighted keyword found in the human's key entered input response pattern and then randomly choose a reassembly pattern from the correct decomposition pattern.

There are a few other things but that's basicly it.

What do you think for my input file: .CSV, hash-array table, PS object?

My blog: http://blogs.powershellcentral.com/kscriss/
kscrissUser is Offline
Basic Member
Basic Member
Posts:119

--
01 May 2008 10:25 PM  

Can anyone think of a better way to represent this data in PowerShell? Below you will find a mock up of what I think is the PowerShell equivalent to the Eliza JavaScript input data an example of which is available in the elizadata.js file located at http://www.masswerk.at/elizabot/elizabot.zip  

Here is my PowerShell equivalent:

$InputScript =
   @{ "PreInsertions" = "Not mocked up yet"
      "PostInsertions" = "Not mocked up yet."
      "Initials" = "Not mocked up yet."
      "Quits" = "Not mocked up yet."
      "Finals" = "Not mocked up yet."
      "Synonyms" = "Not mocked up yet."
      "Keywords" = 
         @{"Remember" =
              @{"SortWeight" = 5 
                "Decomposition" =
                   @{"* i remember *" =
                        @("Do you often think of (2) ?",
                          "Does thinking of (2) bring anything else to mind ?",
                          "What else do you recollect ?",
                          "Why do you remember (2) just now ?",
                          "What in the present situation reminds you of (2) ?",
                          "What is the connection between me and (2) ?",
                          "What else does (2) remind you of ?"
                         )
                     "* do you remember *" =  
                        @("Did you think I would forget (2) ?",
                          "Why do you think I should recall (2) now ?",
                          "What about (2) ?",
                          "goto what",
                          "You mentioned (2) ?"
                         )
                    }
               }
           "forget" =
              @{"SortWeight" = 5
                "Decomposition" = 
                   @{"* i forget *" =
                        @("Can you think of why you might forget (2) ?",
                          "Why can't you remember (2) ?",
                          "How often do you think of (2) ?",
                          "Does it bother you to forget that ?",
                          "Could it be a mental block ?",
                          "Are you generally forgetful ?",
                          "Do you think you are suppressing (2) ?"
                         )
                     "* did you forget *" =
                        @("Why do you ask ?",
                          "Are you sure you told me ?",
                          "Would it bother you if I forgot (2) ?",
                          "Why should I recall (2) just now ?",
                          "goto what",
                          "Tell me more about (2)."
                         )
                    }
               }
          }
    }
#
# Sample usage is below
$Inputscript.Keywords.Remember.Decomposition
My blog: http://blogs.powershellcentral.com/kscriss/
kscrissUser is Offline
Basic Member
Basic Member
Posts:119

--
02 May 2008 03:09 PM  
Another kewl usage:

$Inputscript.Keywords.ContainsKey("Remember")
TRUE
:)
My blog: http://blogs.powershellcentral.com/kscriss/
You are not authorized to post a reply.

Active Forums 4.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • ShellTools, LLC • Microsoft Windows Server 2008 footer
footer