Thread: [Fremantle Maemo5+Harmattan Maemo6] Eliza for N9 and N900
View Single Post
Posts: 1,038 | Thanked: 3,980 times | Joined on Nov 2010 @ USA
#1
Since it doesn't look like there is an implementation of ELIZA for Maemo 5 or Harmattan*, I stole the Python code that itself re-interpreted the LISP from another author who translated it from SLIP by the original creator from ca. 1966.

Briefly put, ELIZA is a simulation -- or perhaps rather a parody -- of a 60s-era psychoanalysist. ELIZA uses pattern matching and some cute substitution tricks to produce natural language responses that seem to make sense.

Right now, it's terminal-based, unpackaged, not super clean and possibly buggy. My part, that is, not the stolen code. That's fine.

Also, the choice of DH Connelly's version of the python code was just happenstance. It was the first one I found that seemed to work ok without much tinkering.

To Use: Just unzip the two python scripts anywhere. In the file eliza_main.py, you'll need to comment/uncomment two lines to work on the N900 with python-simplejson package installed. And of course, install package python-simplejson if not present already.

Code:
#Comment this line out for N900/Maemo 5
import json
#Comment this line out for N9/Harmattan
#import simplejson

If you've got a version of python-json for N900 installed somehow, it will probably work without changes.

Then just type

Code:
python eliza_main.py
to start ELIZA in interactive mode. (Optionally make the python files executable with "chmod +x".)

If you'd prefer to run ELIZA in a query mode, use:

Code:
python eliza_main.py -q "Enter your problem here."
replacing the text with your own personal issues, and she'll give you one response for each question.

ELIZA is stateless -- she has no memory of anything you've talked about -- so she performs the same in question mode as she does interactively. Wanna pipe the output to espeak? Go ahead!

Code:
python eliza_main.py "Hello, Eliza"|espeak
Oh, and true to her -- I'm anthropomorphizing here, and she hates that -- 1960s origins, she responds in ALL CAPS! She's not shouting, just classic. Vintage. Whatever.

Maybe if I get a handle on packaging debs, I'll do that here.

*Except maybe if you install a complete version of emacs.
Attached Files
File Type: zip eliza.zip (5.6 KB, 188 views)
 

The Following 7 Users Say Thank You to robthebold For This Useful Post: