diff -ru AI-MegaHAL-0.06/MegaHAL.xs AI-MegaHAL-0.06.mod/MegaHAL.xs --- AI-MegaHAL-0.06/MegaHAL.xs Fri Jan 23 04:31:43 2004 +++ AI-MegaHAL-0.06.mod/MegaHAL.xs Sun Jan 13 02:11:38 2008 @@ -125,6 +125,11 @@ int log void +megahal_learn(input,log) + char* input + int log + +void megahal_output(output) char* output diff -ru AI-MegaHAL-0.06/lib/AI/MegaHAL.pm AI-MegaHAL-0.06.mod/lib/AI/MegaHAL.pm --- AI-MegaHAL-0.06/lib/AI/MegaHAL.pm Mon Nov 26 23:47:20 2007 +++ AI-MegaHAL-0.06.mod/lib/AI/MegaHAL.pm Sun Jan 13 02:11:38 2008 @@ -19,6 +19,7 @@ megahal_initial_greeting megahal_command megahal_do_reply + megahal_learn megahal_output megahal_input megahal_cleanup); @@ -100,6 +101,12 @@ return megahal_do_reply($text,0); } +sub learn() { + my ($self,$text) = @_; + + return megahal_learn($text,0); +} + sub _initialize() { my $self = shift; @@ -144,6 +151,8 @@ $text = $megahal->do_reply($message); +$megahal->learn($message); + =head1 DESCRIPTION Conversation simulators are computer programs which give the appearance of conversing with a user in natural language. Such programs are effective because they exploit the fact that human beings tend to read much more meaning into what is said than is actually there; we are fooled into reading structure into chaos, and we interpret non-sequitur as valid conversation. @@ -185,6 +194,12 @@ $text = $megahal->do_reply($message); Generates reply $text to a given message $message. + +=head2 learn + +$megahal->learn($message); + +Learns from $message without generating a response =head1 BUGS diff -ru AI-MegaHAL-0.06/libmegahal.c AI-MegaHAL-0.06.mod/libmegahal.c --- AI-MegaHAL-0.06/libmegahal.c Sun Mar 11 15:12:31 2007 +++ AI-MegaHAL-0.06.mod/libmegahal.c Sun Jan 13 02:11:38 2008 @@ -470,6 +470,26 @@ } /* + megahal_learn -- + + Take string as input and and learn with no output. + + */ + +void megahal_learn(char *input, int log) +{ + + if (log != 0) + write_input(input); /* log input if so desired */ + + upper(input); + + make_words(input, words); + + learn(model, words); +} + +/* megahal_initial_greeting -- This function returns an initial greeting. It can be used to start diff -ru AI-MegaHAL-0.06/megahal.h AI-MegaHAL-0.06.mod/megahal.h --- AI-MegaHAL-0.06/megahal.h Fri Nov 17 06:45:08 2000 +++ AI-MegaHAL-0.06.mod/megahal.h Sun Jan 13 02:11:39 2008 @@ -10,6 +10,7 @@ char* megahal_initial_greeting(); int megahal_command(char *input); char* megahal_do_reply(char *input, int log); +void megahal_learn(char *input, int log); void megahal_output(char *output); char* megahal_input(char *prompt); void megahal_cleanup();