http://qs321.pair.com?node_id=11113846


in reply to Re^4: Artificial Intelligence experiment
in thread Artificial Intelligence experiment

I might, but no sense reinventing the wheel.

The author, John Nolan, has already provided a web interface with the download from metacpan.org:

#!/usr/bin/perl # This simple script implements a Chatbot::Eliza # object in a cgi program. It uses the CGI.pm module # written by Lincoln Stein. # # Needless to say, you must have the CGI.pm module # installed and working properly with CGI scripts on # your Web server before you can try to run this script. # CGI.pm is not included with Eliza.pm. # # Information about CGI.pm is here: # http://www.genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html use CGI; use Chatbot::Eliza; my $cgi = new CGI; my $chatbot = new Chatbot::Eliza; srand( time ^ ($$ + ($$ << 15)) ); # seed the random number generator print $cgi->header; print $cgi->start_html; print $cgi->start_multipart_form; print $cgi->h2('Eliza session'); # These lines contain the "Eliza" functionality. # User comments are passed through the module's transform # method, and the output is used to prompt the user # for futher input. # if ( $cgi->param() ) { $prompt = $chatbot->transform( $cgi->param('Comment') ); } else { $prompt = $chatbot->transform('Hello'); } $cgi->param('Comment',''); print $cgi->h3($prompt), $cgi->br, $cgi->textarea( -name => 'Comment', -wrap => 'yes', -rows => 3, -columns => 70 ); print $cgi->p, $cgi->submit('Action','Send to Eliza'), $cgi->reset('Reset'); print $cgi->endform; print $cgi->end_html;

I could just put it up on the web as-is, but I very much doubt the Eliza module is installed on my bargain basement hosting service, or that they would be willing to install it for me.

It might be fun to write a web version that doesn't depend on CGI.pm. (or Chatbot::Eliza for that matter) Probably quite doable. The code is well documented and doesn't appear to be too complicated.

I'd probably take a different approach to the whole thing though, like drop the "therapy" angle and have it just be more conversational. Code-wise, I'd also drop the object-orientedness.

Tom