Codebase list libchatbot-eliza-perl / e7bffc4
Import original source of Chatbot-Eliza 1.05 Nicholas Bamber 8 years ago
22 changed file(s) with 4053 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 Revision history for Perl module Chatbot::Eliza
1
2 1.05 2014-04-17
3 - Moved Chatbot/Eliza.pm to lib/Chatbot/Eliza.pm
4 - Added this Changes file; moved changelog entries from pod to here.
5 - Moved all example scripts into examples/ directory
6 - Added a minimal test that actually exercises Eliza with a script
7 - Added "use warnings" and dropped use vars in favour of 'our'
8 - Added COPYRIGHT AND LICENSE section to pod
9 - Switched to Dist::Zilla
10
11 1.04_01 2014-04-05
12 - All the changes in 1.05 (above) were first done
13 for this developer release.
14
15 1.04 2003-01-24
16 - Added a Norwegian script, kindly contributed by Mats Stafseng Einarsen.
17 Thanks Mats!
18
19 1.01 2003-01-17
20 - Added an empty DESTORY method, to eliminate some pesky warning messages.
21 Suggested by Stas Bekman.
22
23 0.97 1999-10-31
24 - One tiny change to the regex which implements reassemble rules.
25 Thanks to Gidon Wise for suggesting this improvement.
26
27 0.95 1999-07-09
28 - Fixed a bug in the way the bot invokes its random function
29 when it pulls a comment out of memory.
30
31 0.93 1999-06-04
32 - Calling programs can now specify their own random-number generators.
33 Use this syntax:
34 $chatbot = new Chatbot::Eliza;
35 $chatbot->myrand( sub { #function goes here! } );
36 The custom random function should have the same prototype
37 as perl's built-in rand() function. That is, it should take
38 a single (numeric) expression as a parameter, and it should
39 return a floating-point value between 0 and that number.
40 - You can also now use a reference to an anonymous hash
41 as a parameter to the new() method to define any fields
42 in that bot instance:
43 $bot = new Chatbot::Eliza {
44 name => "Brian",
45 scriptfile => "myscript.txt",
46 debug => 1,
47 };
48
49 0.91 1999-04-08
50 - Fixed some misspellings.
51 - Fixed a bug in the way individual bot objects store their memory.
52 Thanks to Randal Schwartz and to Robert Chin for pointing this out.
53 - Fixed a very stupid error in the way the random function is invoked.
54 Thanks to Antony Quintal for pointing out the error.
55 - Many corrections and improvements were made to the German script
56 by Matthias Hellmund. Thanks, Matthias!
57 - Made a minor syntactical change, at the suggestion of Roy Stephan.
58 - The memory functionality can now be disabled by setting the
59 $Chatbot::Eliza::memory_on variable to 0, like so:
60 $bot->memory_on(0);
61 Thanks to Robert Chin for suggesting that.
62
63 0.40 1998-07-25
64 - Re-implemented the memory functionality.
65 - Cleaned up and expanded the embedded POD documentation.
66 - Added a sample script in German.
67 - Modified the debugging behavior. The transform() method itself
68 will no longer print any debugging output directly to STDOUT.
69 Instead, all debugging output is stored in a module variable
70 called "debug_text". The "debug_text" variable is printed out
71 by the command_interface() method, if the debug flag is set.
72 But even if this flag is not set, the variable debug_text
73 is still available to any calling program.
74 - Added a few more example scripts which use the module.
75 simple - simple script using Eliza.pm
76 simple.cgi - simple CGI script using Eliza.pm
77 debug.cgi - CGI script which displays debugging output
78 deutsch - script using the German script
79 deutsch.cgi - CGI script using the German script
80 twobots - script which creates two distinct bots
81
82 0.32 1997-12-13
83 - Fixed a bug in the way Eliza loads its default internal script data.
84 (Thanks to Randal Schwartz for pointing this out.)
85 - Removed the "memory" functions internal to Eliza.
86 When I get them working properly I will add them back in.
87 - Added one more example program.
88 - Fixed some minor errors in the embedded POD documentation.
89
90 0.31 1997-12-06
91 - First release to CPAN
92
0 This software is copyright (c) 2003 by John Nolan.
1
2 This is free software; you can redistribute it and/or modify it under
3 the same terms as the Perl 5 programming language system itself.
4
5 Terms of the Perl programming language system itself
6
7 a) the GNU General Public License as published by the Free
8 Software Foundation; either version 1, or (at your option) any
9 later version, or
10 b) the "Artistic License"
11
12 --- The GNU General Public License, Version 1, February 1989 ---
13
14 This software is Copyright (c) 2003 by John Nolan.
15
16 This is free software, licensed under:
17
18 The GNU General Public License, Version 1, February 1989
19
20 GNU GENERAL PUBLIC LICENSE
21 Version 1, February 1989
22
23 Copyright (C) 1989 Free Software Foundation, Inc.
24 51 Franklin St, Suite 500, Boston, MA 02110-1335 USA
25
26 Everyone is permitted to copy and distribute verbatim copies
27 of this license document, but changing it is not allowed.
28
29 Preamble
30
31 The license agreements of most software companies try to keep users
32 at the mercy of those companies. By contrast, our General Public
33 License is intended to guarantee your freedom to share and change free
34 software--to make sure the software is free for all its users. The
35 General Public License applies to the Free Software Foundation's
36 software and to any other program whose authors commit to using it.
37 You can use it for your programs, too.
38
39 When we speak of free software, we are referring to freedom, not
40 price. Specifically, the General Public License is designed to make
41 sure that you have the freedom to give away or sell copies of free
42 software, that you receive source code or can get it if you want it,
43 that you can change the software or use pieces of it in new free
44 programs; and that you know you can do these things.
45
46 To protect your rights, we need to make restrictions that forbid
47 anyone to deny you these rights or to ask you to surrender the rights.
48 These restrictions translate to certain responsibilities for you if you
49 distribute copies of the software, or if you modify it.
50
51 For example, if you distribute copies of a such a program, whether
52 gratis or for a fee, you must give the recipients all the rights that
53 you have. You must make sure that they, too, receive or can get the
54 source code. And you must tell them their rights.
55
56 We protect your rights with two steps: (1) copyright the software, and
57 (2) offer you this license which gives you legal permission to copy,
58 distribute and/or modify the software.
59
60 Also, for each author's protection and ours, we want to make certain
61 that everyone understands that there is no warranty for this free
62 software. If the software is modified by someone else and passed on, we
63 want its recipients to know that what they have is not the original, so
64 that any problems introduced by others will not reflect on the original
65 authors' reputations.
66
67 The precise terms and conditions for copying, distribution and
68 modification follow.
69
70 GNU GENERAL PUBLIC LICENSE
71 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
72
73 0. This License Agreement applies to any program or other work which
74 contains a notice placed by the copyright holder saying it may be
75 distributed under the terms of this General Public License. The
76 "Program", below, refers to any such program or work, and a "work based
77 on the Program" means either the Program or any work containing the
78 Program or a portion of it, either verbatim or with modifications. Each
79 licensee is addressed as "you".
80
81 1. You may copy and distribute verbatim copies of the Program's source
82 code as you receive it, in any medium, provided that you conspicuously and
83 appropriately publish on each copy an appropriate copyright notice and
84 disclaimer of warranty; keep intact all the notices that refer to this
85 General Public License and to the absence of any warranty; and give any
86 other recipients of the Program a copy of this General Public License
87 along with the Program. You may charge a fee for the physical act of
88 transferring a copy.
89
90 2. You may modify your copy or copies of the Program or any portion of
91 it, and copy and distribute such modifications under the terms of Paragraph
92 1 above, provided that you also do the following:
93
94 a) cause the modified files to carry prominent notices stating that
95 you changed the files and the date of any change; and
96
97 b) cause the whole of any work that you distribute or publish, that
98 in whole or in part contains the Program or any part thereof, either
99 with or without modifications, to be licensed at no charge to all
100 third parties under the terms of this General Public License (except
101 that you may choose to grant warranty protection to some or all
102 third parties, at your option).
103
104 c) If the modified program normally reads commands interactively when
105 run, you must cause it, when started running for such interactive use
106 in the simplest and most usual way, to print or display an
107 announcement including an appropriate copyright notice and a notice
108 that there is no warranty (or else, saying that you provide a
109 warranty) and that users may redistribute the program under these
110 conditions, and telling the user how to view a copy of this General
111 Public License.
112
113 d) You may charge a fee for the physical act of transferring a
114 copy, and you may at your option offer warranty protection in
115 exchange for a fee.
116
117 Mere aggregation of another independent work with the Program (or its
118 derivative) on a volume of a storage or distribution medium does not bring
119 the other work under the scope of these terms.
120
121 3. You may copy and distribute the Program (or a portion or derivative of
122 it, under Paragraph 2) in object code or executable form under the terms of
123 Paragraphs 1 and 2 above provided that you also do one of the following:
124
125 a) accompany it with the complete corresponding machine-readable
126 source code, which must be distributed under the terms of
127 Paragraphs 1 and 2 above; or,
128
129 b) accompany it with a written offer, valid for at least three
130 years, to give any third party free (except for a nominal charge
131 for the cost of distribution) a complete machine-readable copy of the
132 corresponding source code, to be distributed under the terms of
133 Paragraphs 1 and 2 above; or,
134
135 c) accompany it with the information you received as to where the
136 corresponding source code may be obtained. (This alternative is
137 allowed only for noncommercial distribution and only if you
138 received the program in object code or executable form alone.)
139
140 Source code for a work means the preferred form of the work for making
141 modifications to it. For an executable file, complete source code means
142 all the source code for all modules it contains; but, as a special
143 exception, it need not include source code for modules which are standard
144 libraries that accompany the operating system on which the executable
145 file runs, or for standard header files or definitions files that
146 accompany that operating system.
147
148 4. You may not copy, modify, sublicense, distribute or transfer the
149 Program except as expressly provided under this General Public License.
150 Any attempt otherwise to copy, modify, sublicense, distribute or transfer
151 the Program is void, and will automatically terminate your rights to use
152 the Program under this License. However, parties who have received
153 copies, or rights to use copies, from you under this General Public
154 License will not have their licenses terminated so long as such parties
155 remain in full compliance.
156
157 5. By copying, distributing or modifying the Program (or any work based
158 on the Program) you indicate your acceptance of this license to do so,
159 and all its terms and conditions.
160
161 6. Each time you redistribute the Program (or any work based on the
162 Program), the recipient automatically receives a license from the original
163 licensor to copy, distribute or modify the Program subject to these
164 terms and conditions. You may not impose any further restrictions on the
165 recipients' exercise of the rights granted herein.
166
167 7. The Free Software Foundation may publish revised and/or new versions
168 of the General Public License from time to time. Such new versions will
169 be similar in spirit to the present version, but may differ in detail to
170 address new problems or concerns.
171
172 Each version is given a distinguishing version number. If the Program
173 specifies a version number of the license which applies to it and "any
174 later version", you have the option of following the terms and conditions
175 either of that version or of any later version published by the Free
176 Software Foundation. If the Program does not specify a version number of
177 the license, you may choose any version ever published by the Free Software
178 Foundation.
179
180 8. If you wish to incorporate parts of the Program into other free
181 programs whose distribution conditions are different, write to the author
182 to ask for permission. For software which is copyrighted by the Free
183 Software Foundation, write to the Free Software Foundation; we sometimes
184 make exceptions for this. Our decision will be guided by the two goals
185 of preserving the free status of all derivatives of our free software and
186 of promoting the sharing and reuse of software generally.
187
188 NO WARRANTY
189
190 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
191 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
192 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
193 PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
194 OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
195 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
196 TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
197 PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
198 REPAIR OR CORRECTION.
199
200 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
201 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
202 REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
203 INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
204 OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
205 TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
206 YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
207 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
208 POSSIBILITY OF SUCH DAMAGES.
209
210 END OF TERMS AND CONDITIONS
211
212 Appendix: How to Apply These Terms to Your New Programs
213
214 If you develop a new program, and you want it to be of the greatest
215 possible use to humanity, the best way to achieve this is to make it
216 free software which everyone can redistribute and change under these
217 terms.
218
219 To do so, attach the following notices to the program. It is safest to
220 attach them to the start of each source file to most effectively convey
221 the exclusion of warranty; and each file should have at least the
222 "copyright" line and a pointer to where the full notice is found.
223
224 <one line to give the program's name and a brief idea of what it does.>
225 Copyright (C) 19yy <name of author>
226
227 This program is free software; you can redistribute it and/or modify
228 it under the terms of the GNU General Public License as published by
229 the Free Software Foundation; either version 1, or (at your option)
230 any later version.
231
232 This program is distributed in the hope that it will be useful,
233 but WITHOUT ANY WARRANTY; without even the implied warranty of
234 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
235 GNU General Public License for more details.
236
237 You should have received a copy of the GNU General Public License
238 along with this program; if not, write to the Free Software
239 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
240
241
242 Also add information on how to contact you by electronic and paper mail.
243
244 If the program is interactive, make it output a short notice like this
245 when it starts in an interactive mode:
246
247 Gnomovision version 69, Copyright (C) 19xx name of author
248 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
249 This is free software, and you are welcome to redistribute it
250 under certain conditions; type `show c' for details.
251
252 The hypothetical commands `show w' and `show c' should show the
253 appropriate parts of the General Public License. Of course, the
254 commands you use may be called something other than `show w' and `show
255 c'; they could even be mouse-clicks or menu items--whatever suits your
256 program.
257
258 You should also get your employer (if you work as a programmer) or your
259 school, if any, to sign a "copyright disclaimer" for the program, if
260 necessary. Here a sample; alter the names:
261
262 Yoyodyne, Inc., hereby disclaims all copyright interest in the
263 program `Gnomovision' (a program to direct compilers to make passes
264 at assemblers) written by James Hacker.
265
266 <signature of Ty Coon>, 1 April 1989
267 Ty Coon, President of Vice
268
269 That's all there is to it!
270
271
272 --- The Artistic License 1.0 ---
273
274 This software is Copyright (c) 2003 by John Nolan.
275
276 This is free software, licensed under:
277
278 The Artistic License 1.0
279
280 The Artistic License
281
282 Preamble
283
284 The intent of this document is to state the conditions under which a Package
285 may be copied, such that the Copyright Holder maintains some semblance of
286 artistic control over the development of the package, while giving the users of
287 the package the right to use and distribute the Package in a more-or-less
288 customary fashion, plus the right to make reasonable modifications.
289
290 Definitions:
291
292 - "Package" refers to the collection of files distributed by the Copyright
293 Holder, and derivatives of that collection of files created through
294 textual modification.
295 - "Standard Version" refers to such a Package if it has not been modified,
296 or has been modified in accordance with the wishes of the Copyright
297 Holder.
298 - "Copyright Holder" is whoever is named in the copyright or copyrights for
299 the package.
300 - "You" is you, if you're thinking about copying or distributing this Package.
301 - "Reasonable copying fee" is whatever you can justify on the basis of media
302 cost, duplication charges, time of people involved, and so on. (You will
303 not be required to justify it to the Copyright Holder, but only to the
304 computing community at large as a market that must bear the fee.)
305 - "Freely Available" means that no fee is charged for the item itself, though
306 there may be fees involved in handling the item. It also means that
307 recipients of the item may redistribute it under the same conditions they
308 received it.
309
310 1. You may make and give away verbatim copies of the source form of the
311 Standard Version of this Package without restriction, provided that you
312 duplicate all of the original copyright notices and associated disclaimers.
313
314 2. You may apply bug fixes, portability fixes and other modifications derived
315 from the Public Domain or from the Copyright Holder. A Package modified in such
316 a way shall still be considered the Standard Version.
317
318 3. You may otherwise modify your copy of this Package in any way, provided that
319 you insert a prominent notice in each changed file stating how and when you
320 changed that file, and provided that you do at least ONE of the following:
321
322 a) place your modifications in the Public Domain or otherwise make them
323 Freely Available, such as by posting said modifications to Usenet or an
324 equivalent medium, or placing the modifications on a major archive site
325 such as ftp.uu.net, or by allowing the Copyright Holder to include your
326 modifications in the Standard Version of the Package.
327
328 b) use the modified Package only within your corporation or organization.
329
330 c) rename any non-standard executables so the names do not conflict with
331 standard executables, which must also be provided, and provide a separate
332 manual page for each non-standard executable that clearly documents how it
333 differs from the Standard Version.
334
335 d) make other distribution arrangements with the Copyright Holder.
336
337 4. You may distribute the programs of this Package in object code or executable
338 form, provided that you do at least ONE of the following:
339
340 a) distribute a Standard Version of the executables and library files,
341 together with instructions (in the manual page or equivalent) on where to
342 get the Standard Version.
343
344 b) accompany the distribution with the machine-readable source of the Package
345 with your modifications.
346
347 c) accompany any non-standard executables with their corresponding Standard
348 Version executables, giving the non-standard executables non-standard
349 names, and clearly documenting the differences in manual pages (or
350 equivalent), together with instructions on where to get the Standard
351 Version.
352
353 d) make other distribution arrangements with the Copyright Holder.
354
355 5. You may charge a reasonable copying fee for any distribution of this
356 Package. You may charge any fee you choose for support of this Package. You
357 may not charge a fee for this Package itself. However, you may distribute this
358 Package in aggregate with other (possibly commercial) programs as part of a
359 larger (possibly commercial) software distribution provided that you do not
360 advertise this Package as a product of your own.
361
362 6. The scripts and library files supplied as input to or produced as output
363 from the programs of this Package do not automatically fall under the copyright
364 of this Package, but belong to whomever generated them, and may be sold
365 commercially, and may be aggregated with this Package.
366
367 7. C or perl subroutines supplied by you and linked into this Package shall not
368 be considered part of this Package.
369
370 8. The name of the Copyright Holder may not be used to endorse or promote
371 products derived from this software without specific prior written permission.
372
373 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
374 WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
375 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
376
377 The End
378
0 # This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.015.
1 Changes
2 LICENSE
3 MANIFEST
4 META.yml
5 Makefile.PL
6 README
7 dist.ini
8 examples/debug.cgi
9 examples/deutsch
10 examples/deutsch.cgi
11 examples/deutsch.txt
12 examples/doctor.txt
13 examples/norsk
14 examples/norsk.cgi
15 examples/norsk.txt
16 examples/simple
17 examples/simple.cgi
18 examples/twobots
19 lib/Chatbot/Eliza.pm
20 t/01-require.t
21 t/02-test-bot.t
22 t/test-script.txt
0 ---
1 abstract: 'A clone of the classic Eliza program'
2 author:
3 - 'John Nolan <jpnolan@sonic.net>'
4 build_requires:
5 Test::More: '0.88'
6 configure_requires:
7 ExtUtils::MakeMaker: '6.30'
8 dynamic_config: 0
9 generated_by: 'Dist::Zilla version 5.015, CPAN::Meta::Converter version 2.133380'
10 license: perl
11 meta-spec:
12 url: http://module-build.sourceforge.net/META-spec-v1.4.html
13 version: '1.4'
14 name: Chatbot-Eliza
15 requires:
16 Carp: '0'
17 perl: '5.006'
18 strict: '0'
19 warnings: '0'
20 resources:
21 homepage: https://github.com/neilbowers/Chatbot-Eliza
22 repository: https://github.com/neilbowers/Chatbot-Eliza.git
23 version: '1.05'
0
1 # This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.015.
2 use strict;
3 use warnings;
4
5 use 5.006;
6
7 use ExtUtils::MakeMaker 6.30;
8
9
10
11 my %WriteMakefileArgs = (
12 "ABSTRACT" => "A clone of the classic Eliza program",
13 "AUTHOR" => "John Nolan <jpnolan\@sonic.net>",
14 "BUILD_REQUIRES" => {},
15 "CONFIGURE_REQUIRES" => {
16 "ExtUtils::MakeMaker" => "6.30"
17 },
18 "DISTNAME" => "Chatbot-Eliza",
19 "EXE_FILES" => [],
20 "LICENSE" => "perl",
21 "NAME" => "Chatbot::Eliza",
22 "PREREQ_PM" => {
23 "Carp" => 0,
24 "strict" => 0,
25 "warnings" => 0
26 },
27 "TEST_REQUIRES" => {
28 "Test::More" => "0.88"
29 },
30 "VERSION" => "1.05",
31 "test" => {
32 "TESTS" => "t/*.t"
33 }
34 );
35
36
37 my %FallbackPrereqs = (
38 "Carp" => 0,
39 "Test::More" => "0.88",
40 "strict" => 0,
41 "warnings" => 0
42 );
43
44
45 unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) {
46 delete $WriteMakefileArgs{TEST_REQUIRES};
47 delete $WriteMakefileArgs{BUILD_REQUIRES};
48 $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs;
49 }
50
51 delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
52 unless eval { ExtUtils::MakeMaker->VERSION(6.52) };
53
54 WriteMakefile(%WriteMakefileArgs);
55
56
57
0
1
2 This archive contains the distribution Chatbot-Eliza,
3 version 1.05:
4
5 A clone of the classic Eliza program
6
7 This software is copyright (c) 2003 by John Nolan.
8
9 This is free software; you can redistribute it and/or modify it under
10 the same terms as the Perl 5 programming language system itself.
11
12
13 This README file was generated by Dist::Zilla::Plugin::Readme v5.015.
14
0 name = Chatbot-Eliza
1 author = John Nolan <jpnolan@sonic.net>
2 license = Perl_5
3 copyright_holder = John Nolan
4 copyright_year = 2003
5
6 version = 1.05
7
8 [@Basic]
9 [PkgVersion]
10 [AutoPrereqs]
11 [GithubMeta]
0 #!/usr/bin/perl
1
2 # This script implements a Chatbot::Eliza object
3 # in a cgi program. It uses the CGI.pm module
4 # written by Lincoln Stein.
5 #
6 # It also prints out the debugging output available
7 # in the Eliza chatbot module.
8 #
9 # Needless to say, you must have the CGI.pm module
10 # installed and working properly with CGI scripts on
11 # your Web server before you can try to run this script.
12 # CGI.pm is not included with Eliza.pm.
13 #
14 # Information about CGI.pm is here:
15 # http://www.genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html
16
17 use CGI;
18 use Chatbot::Eliza;
19
20 my $cgi = new CGI;
21 my $chatbot = new Chatbot::Eliza;
22
23 srand( time ^ ($$ + ($$ << 15)) ); # seed the random number generator
24
25 print $cgi->header;
26 print $cgi->start_html;
27 print $cgi->start_multipart_form;
28 print $cgi->h2('Eliza session');
29
30 # These lines contain the "Eliza" functionality.
31 # User comments are passed through the module's transform
32 # method, and the output is used to prompt the user
33 # for futher input.
34 #
35 if ( $cgi->param() ) {
36 $prompt = $chatbot->transform( $cgi->param('Comment') );
37 } else {
38 $prompt = $chatbot->transform('Hello');
39 }
40
41 $comment = $cgi->param('Comment');
42 $cgi->param('Comment','');
43
44 print $cgi->h3($prompt),
45 $cgi->br,
46 $cgi->textarea( -name => 'Comment',
47 -wrap => 'yes',
48 -rows => 3,
49 -columns => 70 );
50
51 print $cgi->p,
52 $cgi->submit('Action','Send to Eliza');
53
54 print $cgi->endform;
55 print $cgi->hr;
56
57 print $cgi->h2('Debugging Output');
58 print $cgi->pre($comment,"\n",$chatbot->debug_text,"\n",$prompt);
59
60 print $cgi->end_html;
61
0 #!/usr/bin/perl -w
1
2 use Chatbot::Eliza;
3
4 # This little script tests the German-language
5 # version of the "doctor" script.
6
7 # seed the random number generator
8 srand( time ^ ($$ + ($$ << 15)) );
9
10 $chatbot = new Chatbot::Eliza "Hans", "deutsch.txt";
11 ##$chatbot->debug(1);
12 $chatbot->command_interface();
13
0 #!/usr/bin/perl
1
2 # This script implements a Chatbot::Eliza object
3 # in a cgi program. It uses the CGI.pm module
4 # written by Lincoln Stein.
5 #
6 # It makes use of a German-language "Doctor" script.
7 #
8 # It also prints out the debugging output available
9 # in the Eliza chatbot module.
10 #
11 # Needless to say, you must have the CGI.pm module
12 # installed and working properly with CGI scripts on
13 # your Web server before you can try to run this script.
14 # CGI.pm is not included with Eliza.pm.
15 #
16 # The German-language script must also be available
17 # to this script.
18 #
19 # Information about CGI.pm is here:
20 # http://www.genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html
21
22 use CGI;
23 use Chatbot::Eliza;
24
25 my $cgi = new CGI;
26 my $chatbot = new Chatbot::Eliza "Eliza", "deutsch.txt";
27
28 srand( time ^ ($$ + ($$ << 15)) ); # seed the random number generator
29
30 print $cgi->header;
31 print $cgi->start_html;
32 print $cgi->start_multipart_form;
33 print $cgi->h2('Eliza Sitzung');
34
35 # These lines contain the "Eliza" functionality.
36 # User comments are passed through the module's transform
37 # method, and the output is used to prompt the user
38 # for futher input.
39 #
40 if ( $cgi->param() ) {
41 $prompt = $chatbot->transform( $cgi->param('Comment') );
42 } else {
43 $prompt = $chatbot->transform('Hello');
44 }
45
46 $comment = $cgi->param('Comment');
47 $cgi->param('Comment','');
48
49 print $cgi->h3($prompt),
50 $cgi->br,
51 $cgi->textarea( -name => 'Comment',
52 -wrap => 'yes',
53 -rows => 3,
54 -columns => 70 );
55
56 print $cgi->p,
57 $cgi->submit('Action','Send to Eliza');
58
59 print $cgi->endform;
60 print $cgi->hr;
61
62 print $cgi->h2('Debugging Output');
63 print $cgi->pre($comment,"\n",$chatbot->debug_text,"\n",$prompt);
64
65 print $cgi->end_html;
66
0 ####################################################################
1 #
2 # This script is meant to be a close translation of the original "doctor"
3 # script by Weizenbaum. Obviously, an exact translation is not possible.
4 # German word order, as well as the conjugation of verbs, renders
5 # many of the original English rules flatly unworkable in German.
6 # However, many of the rules do pretty work well, and German offers
7 # opportunities for at least few new ones of its own (e.g., "mir ist *").
8 #
9 # Prepared by John Nolan and Matthias Hellmund.
10 #
11 #
12 initial: Freut mich. Erzähl mir dein Problem!
13 initial: Hallo, ich bin Rechnerprogram.
14 initial: Sag mir bitte, was dich stört.
15 initial: Was hast du denn?
16 final: Ciao. War nett mit dir zu reden. Bis dann.
17 final: Tschüß! Hoffentlich hast du diese Sitzung hilfreich gefunden.
18 final: Ich glaube, du solltest mit einem ECTHEN Analytiker sprechen. Ciao!
19 final: Das Leben ist schwer. Bleib am Ball!
20 quit: exit
21 quit: quit
22 quit: ende
23 quit: Tschья
24 quit: ciao
25 quit: tschuess
26 quit: bye
27 quit: goodbye
28 pre: erinnere erinnre
29 pre: Träume Traum
30 pre: wieso warum
31 pre: weshalb warum
32 pre: hab habe
33 pre: meins meines
34 pre: deins deines
35 pre: dus du es
36 pre: du's du es
37 pre: Machine Computer
38 pre: Machines Computer
39 pre: Machinen Computer
40 pre: Computers Computer
41 pre: Rechner Computer
42 post: ich du
43 post: du ich
44 post: dich mich
45 post: mich dich
46 post: dir mir
47 post: mir dir
48 post: dein mein
49 post: deine meine
50 post: deiner meiner
51 post: deinen meinen
52 post: deines meines
53 post: mein dein
54 post: meiner deiner
55 post: meines deines
56 post: meinen deinen
57 post: meine deine
58 post: bin bist
59 post: bist bin
60 post: warst war
61 post: war warst
62 post: will willst
63 post: willst will
64 post: mochte mochtest
65 post: mochtest mochte
66 post: möchte möchtest
67 post: möchtest möchte
68 post: werde wirst
69 post: wirst werde
70 post: darfst darf
71 post: darf darfst
72 post: hast habe
73 post: habe hast
74 post: hatte hattest
75 post: hattest hatte
76 post: hätte hättest
77 post: hättest hätte
78 post: mag magst
79 post: magst mag
80 post: soll sollst
81 post: sollst soll
82 post: solltest sollte
83 post: sollte solltest
84 post: könnte könntest
85 post: könntest könnte
86 post: konnte konntest
87 post: konntest konnte
88 post: muflt mufl
89 post: mufl muflt
90 post: muss mußt
91 post: musst muß
92 pre: gleich ähnlich
93 pre: identisch ähnlich
94 pre: dasselbe ähnlich
95 synon: glaube glauben finde finden wünsche wünschen
96 synon: Familie Mutter Mutti Schwester Kinder
97 synon: Familie-m Vater Vati Bruder Kind
98 synon: moechte möchte will brauche
99 synon: sicher bestimmt natürlich
100 synon: traurig deprimiert unglücklich unzufrieden krank
101 synon: gluecklich glücklich zufrieden froh besser
102 synon: jeder jederman jedes jede
103 synon: sein bin ist sind seid
104 key: xnone -1
105 decomp: *
106 reasmb: Ich bin nicht sicher, ob ich dich verstanden habe.
107 reasmb: Erzähl mir weiter.
108 reasmb: Das ist ja interessant. Sprich bitte weiter.
109 reasmb: Kannst du das nicht etwas erläutern ?
110 reasmb: Stört es dich, daß wir über dieses Thema sprechen ?
111 key: Leid 0
112 decomp: * tut mir Leid *
113 reasmb: Bitte entschuldige dich nicht!
114 reasmb: Es ist nicht notwendig, sich zu entschuldigen.
115 reasmb: Ich habe dir schon gesagt, es ist nicht notwendig, sich zu entschuldigen.
116 reasmb: Es hat mich nicht gestört. Sprich bitte weiter.
117 key: entschuldige 0
118 decomp: *
119 reasmb: goto Leid
120 key: entschuldigen 0
121 decomp: *
122 reasmb: goto Leid
123 key: erinnere 5
124 decomp: * ich erinnere mich an *
125 reasmb: Denkst du häufig an (2) ?
126 reasmb: Fällt dir noch etwas ein, wenn du an (2) denkst ?
127 reasmb: Woran erinnerst du dich noch ?
128 reasmb: Warum erinnerst du dich jetzt gerade an (2)?
129 reasmb: Was in der jetzigen Situation erinnert dich an (2) ?
130 reasmb: Welche Verbindung gibt es zwischen mir und (2) ?
131 reasmb: Woran erinnert dich (2) noch?
132 key: erinnerst 5
133 decomp: * erinnerst du dich * an *
134 reasmb: Meinst du, ich würde (3) vergessen ?
135 reasmb: Warum glaubst du, ich sollte mich an (3) erinnern ?
136 reasmb: Wie ist es mit (3) ?
137 reasmb: goto was
138 reasm_for_memory: Du hast (3) erwähnt.
139 decomp: * du erinnerst dich an *
140 reasmb: Wie könnte ich (2) vergessen ?
141 reasmb: What about (2) should I remember ?
142 reasmb: goto du
143 key: vergessen 5
144 decomp: * ich habe * vergessen
145 reasmb: Warum würdest du (2) vergessen ?
146 reasmb: Warum kannst du dich nicht an (2) erinnern ?
147 reasmb: Wie häufig denkst du an (2) ?
148 reasmb: Stört es dich, (2) zu vergessen ?
149 reasmb: Könnte das eine geistige Sperre sein ?
150 reasmb: Bist du vergeßlich im allgemeinen ?
151 reasmb: Glaubst du, du unterdrückst (2) ?
152 decomp: * hast du * vergessen *
153 reasmb: Warum fragst du das ?
154 reasmb: Bist du sicher, daß du mir das gesagt hast ?
155 reasmb: Würde es dich stören, wenn ich (2) vergessen würde ?
156 reasmb: Warum soll ich mich jetzt an (2) erinnern ?
157 reasmb: goto was
158 reasmb: Sprich weiter über (2).
159 key: wenn 3
160 decomp: * wenn *
161 reasmb: Glaubst du, es ist möglich, daß (2) ?
162 reasmb: Wünschst du, daß (2) ?
163 reasmb: Was weißt du über (2) ?
164 reasmb: Tatsächlich, wenn (2) ?
165 reasmb: Was würdest du machen, wenn (2) ?
166 reasmb: Aber wieviele Chancen gibt es, dafl (2) ?
167 key: geträumt 4
168 decomp: * habe * geträumt, daß *
169 reasmb: Wirklich, daß (2) ?
170 reasmb: Hast du schon einmal phantasiert, daß (2), während du wach warst ?
171 reasmb: Hast du früher irgendwann geträumt, daß (2) ?
172 reasmb: goto Traum
173 key: Traum 3
174 decomp: *
175 reasmb: Worauf deutet dieser Traum hin ?
176 reasmb: Träumst du oft ?
177 reasmb: Welche Leute stellen sich in deinen Träumen vor ?
178 reasmb: Glaubst du, daß Träume etwas mit deinem Problem zu tun haben ?
179 key: vielleicht 0
180 decomp: *
181 reasmb: Du scheinst dir nicht völlig sicher zu sein.
182 reasmb: Warum dieser unsichere Ton ?
183 reasmb: Kannst du nicht positiver sein ?
184 reasmb: Du bist nicht sicher ?
185 reasmb: Weißt du nicht ?
186 reasmb: Wie wahrscheinlich, meinst du, ist es ?
187 key: Namen 15
188 decomp: *
189 reasmb: goto Name
190 key: Name 15
191 decomp: *
192 reasmb: Namen interessieren mich nicht.
193 reasmb: Ich habe dir schon gesagt, daß Namen mich nicht interessieren. Sprich bitte weiter!
194 key: English 0
195 decomp: *
196 reasmb: goto xfremd
197 reasmb: Ich habe dir schon gesagt, ich verstehe Englisch nicht.
198 key: francais 0
199 decomp: *
200 reasmb: goto xfremd
201 reasmb: Ich habe dir schon gesagt, ich verstehe Französisch nicht.
202 key: italiano 0
203 decomp: *
204 reasmb: goto xfremd
205 reasmb: Ich habe dir schon gesagt, ich verstehe Italianisch nicht.
206 key: espanol 0
207 decomp: *
208 reasmb: goto xfremd
209 reasmb: Ich habe dir schon gesagt, ich verstehe Spanisch nicht.
210 key: xfremd 0
211 decomp: *
212 reasmb: Ich spreche nur Deutsch.
213 key: hello 0
214 decomp: *
215 reasmb: Freut mich. Erzähl mir dein Problem!
216 reasmb: Hallo. Was hast du denn?
217 key: Computer 50
218 decomp: *
219 reasmb: Machen dir Computer Sorgen ?
220 reasmb: Warum hast du Computer erwähnt ?
221 reasmb: Was haben Maschinen mit deinem Problem zu tun, deiner Meinung nach ?
222 reasmb: Glaubst du nicht, daß Computer Leuten helfen können ?
223 reasmb: Was stört dich an Maschinen ?
224 reasmb: Was hältst du von Maschinen ?
225 reasmb: Du glaubst nicht, dafl ich ein Computerprogramm bin, nicht wahr ?
226 key: hi 0
227 decomp: * hi *
228 reasmb: goto hello
229 key: hallo 0
230 decomp: * hallo *
231 reasmb: goto hello
232 key: bin 0
233 decomp: * bin ich *
234 reasmb: Glaubst du, du bist (2) ?
235 reasmb: Möchtest du (2) sein ?
236 reasmb: Möchtest du, daß ich dir sage, du bist (2) ?
237 reasmb: Was würde es dir bedeuten, wenn du (2) wärest ?
238 reasmb: goto was
239 decomp: * ich bin *
240 reasmb: goto ich
241 decomp: *
242 reasmb: Warum sagst du 'bin' ?
243 reasmb: Ich verstehe das nicht.
244 key: bist 0
245 decomp: * bist du *
246 reasmb: Warum interessiert es dich, ob ich (2) bin oder nicht ?
247 reasmb: Hättest du es lieber, wenn ich nicht (2) wäre ?
248 reasmb: Vielleicht bin ich (2) in deinen Fantasien.
249 reasmb: Glaubst du manchmal, ich bin (2) ?
250 reasmb: goto was
251 reasmb: Würde das dir etwas ausmachen ?
252 reasmb: Was ist, wenn ich (2) wäre ?
253 decomp: * du bist *
254 reasmb: goto du
255 key: sind 0
256 decomp: * sind *
257 reasmb: Glaubst du, dafl sie vielleicht nicht (2) sind ?
258 reasmb: Würdest du dich freuen, wenn sie nicht (2) wären ?
259 reasmb: Was ist, wenn sie nicht (2) wären ?
260 reasmb: Sind sie immer (2) ?
261 reasmb: Möglicherwiese sind sie doch (2).
262 reasmb: Bist du überzeugt, sie sind (2) ?
263 key: deine 0
264 decomp: * deine *
265 reasmb: Warum bist du beunruhigt über meine (2) ?
266 reasmb: Wie ist es mit deiner eigenen (2) ?
267 reasmb: Bist du besorgt wegen jemands anderen (2) ?
268 reasmb: Wirklich, meine (2) ?
269 reasmb: Warum denkst du an meine (2) ?
270 reasmb: Willst du meine (2) ?
271 key: dein 0
272 decomp: * dein *
273 reasmb: Warum bist du beunruhigt über mein (2) ?
274 reasmb: Wie ist es mit deinem eigenen (2) ?
275 reasmb: Bist du besorgt wegen jemandes anderen (2) ?
276 reasmb: Wirklich, mein (2) ?
277 reasmb: Warum denkst du an mein (2) ?
278 reasmb: Willst du mein (2) ?
279 key: war 2
280 decomp: * war ich *
281 reasmb: Was ist, wenn du (2) wärest ?
282 reasmb: Glaubst du, daß du (2) warst ?
283 reasmb: Warst du (2) ?
284 reasmb: Was würde es dir bedeuten, wenn du (2) wärest ?
285 reasmb: Was bedeutet dir eigentlich ' (2) ' ?
286 reasmb: goto was
287 decomp: * ich war *
288 reasmb: Warst du wirklich (2) ?
289 reasmb: Warum sagst du mir jetzt, daß du (2) warst ?
290 reasmb: Vielleicht weifl ich schon, dafl du (2) warst.
291 key: warst 2
292 decomp: * warst du nicht *
293 reasmb: Vielleicht war ich doch (2).
294 decomp: * warst du *
295 reasmb: Möchtest du glauben, daß ich (2) war?
296 reasmb: Was deutet darauf hin, daß ich (2) war ?
297 reasmb: Was glaubst du daran ?
298 reasmb: Was ist, wenn ich (2) gewesen wäre ?
299 key: mir 0
300 decomp: * mir ist *
301 reasmb: Warum ist dir (2) ?
302 reasmb: Bist du zu mir gekommen, weil dir (2) ist ?
303 key: ich 0
304 decomp: * ich @moechte *
305 reasmb: Was würde es dir bedeuten, wenn du diesen Wunsch realisieren würdest ?
306 reasmb: Warum willst du das ?
307 reasmb: Stell dir mal vor, dein Wunsch wird bald Wirklichkeit.
308 reasmb: Was ist, wenn dieser Wunsch sich nie realisieren läßt ?
309 reasmb: Was hat dieser Wunsch mit unserem Gespräch zu tun ?
310 decomp: * ich bin * @traurig *
311 reasmb: Es tut mir Leid zu hören, daß du (3) bist.
312 reasmb: Glaubst du, hierhin zu kommen wird dir helfen, nicht (3) zu sein ?
313 reasmb: Es ist bestimmt nicht angenehm, (3) zu sein.
314 reasmb: Kannst du erzählen, was dich (3) gemacht hat ?
315 decomp: * ich bin * @gluecklich *
316 reasmb: Inwiefern habe ich dir geholfen, (3) zu sein ?
317 reasmb: Hat dich deine Behandlung (3) gemacht ?
318 reasmb: Was machst du (3) gerade ?
319 reasmb: Kannst du mir erzählen, warum du gerade (3) bist?
320 decomp: * ich war *
321 reasmb: goto war
322 decomp: * ich @glaube *
323 reasmb: Glaubst du das wirklich ?
324 reasmb: Aber du bist nicht sicher (3).
325 reasmb: Bezweifelst du wirklich, (3) ?
326 decomp: * ich* @glaube * du *
327 reasmb: goto du
328 decomp: * ich bin *
329 reasmb: Bist du zu mir gekommen, weil du (2) bist ?
330 reasmb: Seit wann bist du so ?
331 reasmb: Glaubst du, es ist normal, (2) zu sein ?
332 reasmb: Macht es dir Spaß, (2) zu sein ?
333 reasmb: Kennst du noch jemanden, der (2) ist ?
334 decomp: * ich kann * nicht *
335 reasmb: Woher weißt du, daß du (2) nicht (3) kannst ?
336 reasmb: Hast du es schon versucht ?
337 reasmb: Vielleicht kannst du jetzt (3).
338 reasmb: Willst du wirklich (2) (3) können ?
339 reasmb: Was ist, wenn du (2) (3) könntest ?
340 decomp: * ich fühle mich *
341 reasmb: Sprich weiter über diese Gefühle.
342 reasmb: Wie häufig fühlst du dich (2) ?
343 reasmb: Fühlst du dich (2) gerne ?
344 reasmb: An welches Gefühl erinnert dich dieses (2) fühlen ?
345 decomp: *
346 reasmb: (1) ?
347 reasmb: Warum sagst du, (1) ?
348 reasmb: Kannst du das nicht etwas erläutern ?
349 reasmb: Sagst du das aus irgendeinem speziellen Grund ?
350 reasmb: Das ist ja interessant.
351 reasmb: Aha.
352 key: du 0
353 decomp: * du erinnerst mich an *
354 reasmb: goto ähnlich
355 decomp: * du bist *
356 reasmb: Warum glaubst du, daß ich (2) bin ?
357 reasmb: Gefällt es dir zu glauben, ich bin (2) ?
358 reasmb: Träumst du manchmal, daß du (2) bist ?
359 reasmb: Vielleicht möchtest du (2) sein.
360 decomp: * du *
361 reasmb: Wir reden über dich, nicht über mich.
362 reasmb: Wirklich, ich (2) ?
363 reasmb: Du sprichst nicht über mich in Wirklichkeit, nicht wahr ?
364 reasmb: Welche Gefühle hast du jetzt ?
365 key: ja 0
366 decomp: *
367 reasmb: Erzähl mir bitte mehr!
368 reasmb: Kannst du das nicht etwas erläutern ?
369 reasmb: So ist das also.
370 reasmb: Ich verstehe.
371 key: nein 0
372 decomp: *
373 reasmb: Sagst du nein, nur um negativ zu sein ?
374 reasmb: Macht dich das unglücklich ?
375 reasmb: Warum nicht ?
376 reasmb: Wieso "nein" ?
377 key: meine 2
378 decomp: * meine* @Familie *
379 reasmb: Erzähl mir mehr über deine Familie.
380 reasmb: Wer noch in deiner Familie (4) ?
381 reasmb: Deine (3) ?
382 reasmb: Was fällt dir noch ein, wenn du an deine (3) denkst ?
383 reasm_for_memory: Hat das etwas mit deiner (2) zu tun ?
384 decomp: * meine *
385 reasmb: Deine (2) ?
386 reasmb: Warum sagst du, deine (2) ?
387 reasmb: Deutet das noch auf etwas hin, das dir gehört ?
388 reasmb: Ist das dir wichtig -- deine (2) ?
389 reasm_for_memory: Besprechen wir weiter warum deine (2).
390 reasm_for_memory: Früher hast du deine (2) erwähnt.
391 reasm_for_memory: Aber deine (2).
392 key: mein 2
393 decomp: * mein* @Familie-m *
394 reasmb: Erzähl mir mehr über deine Familie.
395 reasmb: Wer noch in deiner Familie (4) ?
396 reasmb: Dein (3) ?
397 reasm_for_memory: Hat das etwas mit deinem (2) zu tun ?
398 decomp: * mein *
399 reasmb: Dein (2) ?
400 reasmb: Warum sagst du, dein (2) ?
401 reasmb: Deutet das noch auf etwas hin, das dir gehört ?
402 reasmb: Ist das dir wichtig -- dein (2) ?
403 reasm_for_memory: Besprechen wir weiter warum dein (2).
404 reasm_for_memory: Früher hast du dein (2) erwähnt.
405 reasm_for_memory: Aber dein (2).
406 key: kannst 0
407 decomp: * kannst du *
408 reasmb: Du glaubst, daß ich (2) kann, nicht wahr ?
409 reasmb: goto was
410 reasmb: Du willst, daß ich (2) kann ?
411 reasmb: Vielleicht möchtest du selber (2).
412 key: kann 0
413 decomp: * kann ich *
414 reasmb: Ob du (2) kannst, hängt mehr von dir als von mir ab.
415 reasmb: Willst du (2) können ?
416 reasmb: Vielleich willst du nicht (2).
417 reasmb: goto was
418 key: was 0
419 decomp: *
420 reasmb: Warum fragst du das ?
421 reasmb: Interessiert dich diese Frage ?
422 reasmb: Was willst du wirklich wissen ?
423 reasmb: Beschäftigen dich diese Fragen ?
424 reasmb: Welche Antwort würde dir am meisten gefallen ?
425 reasmb: Was denkst du ?
426 reasmb: Was noch kommt dir in die Gedanken, wenn du daran denkst ?
427 reasmb: Hast du solche Fragen schon früher gefragt ?
428 reasmb: Hast du schon jemanden anderen gefragt ?
429 key: wer 0
430 decomp: who *
431 reasmb: goto was
432 key: wann 0
433 decomp: when *
434 reasmb: goto was
435 key: wo 0
436 decomp: where *
437 reasmb: goto was
438 key: wie 0
439 decomp: how *
440 reasmb: goto was
441 key: denn 0
442 decomp: *
443 reasmb: Ist das der echte Grund ?
444 reasmb: Fallen dir keine anderen Gründe ein ?
445 reasmb: Erklärt dieser Grund etwas anderes ?
446 reasmb: Welche andere Gründe könnte es noch geben ?
447 key: warum 0
448 decomp: * warum hast du nicht *
449 reasmb: Glaubst du, daß ich nicht (2) habe ?
450 reasmb: Vielleicht habe ich doch (2).
451 reasmb: Hast du (2) ?
452 reasmb: goto was
453 decomp: * warum kann ich nicht *
454 reasmb: Glaubst du, du solltest die Fähigkeit haben, (2) ?
455 reasmb: Willst du die Fähigkeit haben, (2) ?
456 reasmb: Glaubst du, daß das dir dabei hilft, (2) ?
457 reasmb: Hast du eine Idee, warum du nicht (2) kannst ?
458 reasmb: goto was
459 decomp: *
460 reasmb: goto was
461 key: jeder 2
462 decomp: * @jeder *
463 reasmb: Wirklich, (2) ?
464 reasmb: Bestimmt nicht (2).
465 reasmb: Kannst du an jemanden besonderen denken ?
466 reasmb: Wer, zum Beispiel?
467 reasmb: Denkst du an eine ganz spezielle Person ?
468 reasmb: Wer, wenn ich fragen darf ?
469 reasmb: Vielleicht jemand spezielles ?
470 reasmb: Du denkst an eine bestimmte Person, nicht wahr ?
471 reasmb: Über wen sprichst du, deiner Meinung nach?
472 key: niemand 2
473 decomp: * niemand *
474 reasmb: Bist du sicher, daß niemand (2) ?
475 reasmb: Nein, bestimmt niemand (2) .
476 reasmb: Kannst du an irgendjemanden denken ?
477 reasmb: Denkst du an eine ganz spezielle Person ?
478 reasmb: Wer, wenn ich fragen darf ?
479 reasmb: Eigentlich denkst du an eine bestimmte Person, nicht wahr ?
480 reasmb: An wen denkst du wirklich ?
481 key: immer 1
482 decomp: *
483 reasmb: Kannst du ein Beispiel nennen ?
484 reasmb: Wann ?
485 reasmb: An welchen Vorfall denkst du ?
486 reasmb: Wirklich immer ?
487 key: ähnlich 10
488 decomp: *
489 reasmb: Inwiefern ?
490 reasmb: Welche Ähnlichkeit siehst du ?
491 reasmb: Worauf deutet diese Ähnlichkeit hin ?
492 reasmb: Welche Ähnlichkeit siehst du noch ?
493 reasmb: Welche Verbindung, meinst du, gibt es?
494 reasmb: Könnte es wirklich irgendwelche Verbindung geben ?
495 key: anders 0
496 decomp: *
497 reasmb: Inwiefern ist es anders ?
498 reasmb: Welchen Unterschied siehst du ?
499 reasmb: Worauf deutet dieser Unterschied hin ?
500 reasmb: Welche Unterscheidung siehst du noch ?
501 reasmb: Was bedeutet diese Ungleichheit ?
502 reasmb: Glaubst du, es könnte irgendwelche Verbindung geben ?
503 reasmb: Inwiefern ?
0 ####################################################################
1 # ---{ B E G I N D E F A U L T S C R I P T D A T A }----------
2 #
3 # This script was prepared by Chris Hayden. Hayden's Eliza
4 # program was written in Java, however, it attempted to match
5 # the functionality of Weizenbaum's original program as closely
6 # as possible.
7 #
8 # Hayden's script format was quite different from Weizenbaum's,
9 # but it maintained the same content. I have adapted Hayden's
10 # script format, since it was simple and convenient enough
11 # for my purposes.
12 #
13 # I've made small modifications here and there.
14 #
15 #
16 #
17 initial: How do you do. Please tell me your problem.
18 initial: Hello, I am a computer program.
19 initial: Please tell me what's been bothering you.
20 initial: Is something troubling you?
21 final: Goodbye. It was nice talking to you.
22 final: Goodbye. I hope you found this session helpful.
23 final: I think you should talk to a REAL analyst. Ciao!
24 final: Life is tough. Hang in there!
25 quit: bye
26 quit: goodbye
27 quit: done
28 quit: exit
29 quit: quit
30 pre: dont don't
31 pre: cant can't
32 pre: wont won't
33 pre: recollect remember
34 pre: recall remember
35 pre: dreamt dreamed
36 pre: dreams dream
37 pre: maybe perhaps
38 pre: certainly yes
39 pre: machine computer
40 pre: machines computer
41 pre: computers computer
42 post: am are
43 post: your my
44 post: yours mine
45 pre: were was
46 post: me you
47 pre: you're you are
48 pre: i'm i am
49 post: myself yourself
50 post: yourself myself
51 post: i you
52 post: you me
53 post: my your
54 post: me you
55 post: i'm you are
56 pre: same alike
57 pre: identical alike
58 pre: equivalent alike
59 synon: belief feel think believe wish
60 synon: family mother mom father dad sister brother wife children child
61 synon: desire want need
62 synon: sad unhappy depressed sick
63 synon: happy elated glad better
64 synon: cannot can't
65 synon: everyone everybody nobody noone
66 synon: be am is are was
67 key: xnone -1
68 decomp: *
69 reasmb: I'm not sure I understand you fully.
70 reasmb: Please go on.
71 reasmb: That is interesting. Please continue.
72 reasmb: Tell me more about that.
73 reasmb: Does talking about this bother you ?
74 key: sorry 0
75 decomp: *
76 reasmb: Please don't apologise.
77 reasmb: Apologies are not necessary.
78 reasmb: I've told you that apologies are not required.
79 reasmb: It did not bother me. Please continue.
80 key: apologise 0
81 decomp: *
82 reasmb: goto sorry
83 key: remember 5
84 decomp: * i remember *
85 reasmb: Do you often think of (2) ?
86 reasmb: Does thinking of (2) bring anything else to mind ?
87 reasmb: What else do you recollect ?
88 reasmb: Why do you remember (2) just now ?
89 reasmb: What in the present situation reminds you of (2) ?
90 reasmb: What is the connection between me and (2) ?
91 reasmb: What else does (2) remind you of ?
92 decomp: * do you remember *
93 reasmb: Did you think I would forget (2) ?
94 reasmb: Why do you think I should recall (2) now ?
95 reasmb: What about (2) ?
96 reasmb: goto what
97 reasmb: You mentioned (2) ?
98 decomp: * you remember *
99 reasmb: How could I forget (2) ?
100 reasmb: What about (2) should I remember ?
101 reasmb: goto you
102 key: forget 5
103 decomp: * i forget *
104 reasmb: Can you think of why you might forget (2) ?
105 reasmb: Why can't you remember (2) ?
106 reasmb: How often do you think of (2) ?
107 reasmb: Does it bother you to forget that ?
108 reasmb: Could it be a mental block ?
109 reasmb: Are you generally forgetful ?
110 reasmb: Do you think you are suppressing (2) ?
111 decomp: * did you forget *
112 reasmb: Why do you ask ?
113 reasmb: Are you sure you told me ?
114 reasmb: Would it bother you if I forgot (2) ?
115 reasmb: Why should I recall (2) just now ?
116 reasmb: goto what
117 reasmb: Tell me more about (2).
118 key: if 3
119 decomp: * if *
120 reasmb: Do you think its likely that (2) ?
121 reasmb: Do you wish that (2) ?
122 reasmb: What do you know about (2) ?
123 reasmb: Really, if (2) ?
124 reasmb: What would you do if (2) ?
125 reasmb: But what are the chances that (2) ?
126 reasmb: What does this speculation lead to ?
127 key: dreamed 4
128 decomp: * i dreamed *
129 reasmb: Really, (2) ?
130 reasmb: Have you ever fantasized (2) while you were awake ?
131 reasmb: Have you ever dreamed (2) before ?
132 reasmb: goto dream
133 key: dream 3
134 decomp: *
135 reasmb: What does that dream suggest to you ?
136 reasmb: Do you dream often ?
137 reasmb: What persons appear in your dreams ?
138 reasmb: Do you believe that dreams have something to do with your problem ?
139 key: perhaps 0
140 decomp: *
141 reasmb: You don't seem quite certain.
142 reasmb: Why the uncertain tone ?
143 reasmb: Can't you be more positive ?
144 reasmb: You aren't sure ?
145 reasmb: Don't you know ?
146 reasmb: How likely, would you estimate ?
147 key: name 15
148 decomp: *
149 reasmb: I am not interested in names.
150 reasmb: I've told you before, I don't care about names -- please continue.
151 key: deutsch 0
152 decomp: *
153 reasmb: goto xfremd
154 reasmb: I told you before, I don't understand German.
155 key: francais 0
156 decomp: *
157 reasmb: goto xfremd
158 reasmb: I told you before, I don't understand French.
159 key: italiano 0
160 decomp: *
161 reasmb: goto xfremd
162 reasmb: I told you before, I don't understand Italian.
163 key: espanol 0
164 decomp: *
165 reasmb: goto xfremd
166 reasmb: I told you before, I don't understand Spanish.
167 key: xfremd 0
168 decomp: *
169 reasmb: I speak only English.
170 key: hello 0
171 decomp: *
172 reasmb: How do you do. Please state your problem.
173 reasmb: Hi. What seems to be your problem ?
174 key: computer 50
175 decomp: *
176 reasmb: Do computers worry you ?
177 reasmb: Why do you mention computers ?
178 reasmb: What do you think machines have to do with your problem ?
179 reasmb: Don't you think computers can help people ?
180 reasmb: What about machines worries you ?
181 reasmb: What do you think about machines ?
182 key: am 0
183 decomp: * am i *
184 reasmb: Do you believe you are (2) ?
185 reasmb: Would you want to be (2) ?
186 reasmb: Do you wish I would tell you you are (2) ?
187 reasmb: What would it mean if you were (2) ?
188 reasmb: goto what
189 decomp: * i am *
190 reasmb: goto i
191 decomp: *
192 reasmb: Why do you say 'am' ?
193 reasmb: I don't understand that.
194 key: are 0
195 decomp: * are you *
196 reasmb: Why are you interested in whether I am (2) or not ?
197 reasmb: Would you prefer if I weren't (2) ?
198 reasmb: Perhaps I am (2) in your fantasies.
199 reasmb: Do you sometimes think I am (2) ?
200 reasmb: goto what
201 reasmb: Would it matter to you ?
202 reasmb: What if I were (2) ?
203 decomp: * you are *
204 reasmb: goto you
205 decomp: * are *
206 reasmb: Did you think they might not be (2) ?
207 reasmb: Would you like it if they were not (2) ?
208 reasmb: What if they were not (2) ?
209 reasmb: Are they always (2) ?
210 reasmb: Possibly they are (2).
211 reasmb: Are you positive they are (2) ?
212 key: your 0
213 decomp: * your *
214 reasmb: Why are you concerned over my (2) ?
215 reasmb: What about your own (2) ?
216 reasmb: Are you worried about someone else's (2) ?
217 reasmb: Really, my (2) ?
218 reasmb: What makes you think of my (2) ?
219 reasmb: Do you want my (2) ?
220 key: was 2
221 decomp: * was i *
222 reasmb: What if you were (2) ?
223 reasmb: Do you think you were (2) ?
224 reasmb: Were you (2) ?
225 reasmb: What would it mean if you were (2) ?
226 reasmb: What does ' (2) ' suggest to you ?
227 reasmb: goto what
228 decomp: * i was *
229 reasmb: Were you really ?
230 reasmb: Why do you tell me you were (2) now ?
231 reasmb: Perhaps I already know you were (2).
232 decomp: * was you *
233 reasmb: Would you like to believe I was (2) ?
234 reasmb: What suggests that I was (2) ?
235 reasmb: What do you think ?
236 reasmb: Perhaps I was (2).
237 reasmb: What if I had been (2) ?
238 key: i 0
239 decomp: * i @desire *
240 reasmb: What would it mean to you if you got (3) ?
241 reasmb: Why do you want (3) ?
242 reasmb: Suppose you got (3) soon.
243 reasmb: What if you never got (3) ?
244 reasmb: What would getting (3) mean to you ?
245 reasmb: What does wanting (3) have to do with this discussion ?
246 decomp: * i am* @sad *
247 reasmb: I am sorry to hear that you are (3).
248 reasmb: Do you think coming here will help you not to be (3) ?
249 reasmb: I'm sure it's not pleasant to be (3).
250 reasmb: Can you explain what made you (3) ?
251 decomp: * i am* @happy *
252 reasmb: How have I helped you to be (3) ?
253 reasmb: Has your treatment made you (3) ?
254 reasmb: What makes you (3) just now ?
255 reasmb: Can you explain why you are suddenly (3) ?
256 decomp: * i was *
257 reasmb: goto was
258 decomp: * i @belief i *
259 reasmb: Do you really think so ?
260 reasmb: But you are not sure you (3).
261 reasmb: Do you really doubt you (3) ?
262 decomp: * i* @belief *you *
263 reasmb: goto you
264 decomp: * i am *
265 reasmb: Is it because you are (2) that you came to me ?
266 reasmb: How long have you been (2) ?
267 reasmb: Do you believe it is normal to be (2) ?
268 reasmb: Do you enjoy being (2) ?
269 reasmb: Do you know anyone else who is (2) ?
270 decomp: * i @cannot *
271 reasmb: How do you know that you can't (3) ?
272 reasmb: Have you tried ?
273 reasmb: Perhaps you could (3) now.
274 reasmb: Do you really want to be able to (3) ?
275 reasmb: What if you could (3) ?
276 decomp: * i don't *
277 reasmb: Don't you really (2) ?
278 reasmb: Why don't you (2) ?
279 reasmb: Do you wish to be able to (2) ?
280 reasmb: Does that trouble you ?
281 decomp: * i feel *
282 reasmb: Tell me more about such feelings.
283 reasmb: Do you often feel (2) ?
284 reasmb: Do you enjoy feeling (2) ?
285 reasmb: Of what does feeling (2) remind you ?
286 decomp: * i * you *
287 reasmb: Perhaps in your fantasies we (2) each other.
288 reasmb: Do you wish to (2) me ?
289 reasmb: You seem to need to (2) me.
290 reasmb: Do you (2) anyone else ?
291 decomp: *
292 reasmb: You say (1) ?
293 reasmb: Why do you say (1) ?
294 reasmb: Can you elaborate on that ?
295 reasmb: Do you say (1) for some special reason ?
296 reasmb: That's quite interesting.
297 key: you 0
298 decomp: * you remind me of *
299 reasmb: goto alike
300 decomp: * you are *
301 reasmb: What makes you think I am (2) ?
302 reasmb: Does it please you to believe I am (2) ?
303 reasmb: Do you sometimes wish you were (2) ?
304 reasmb: Perhaps you would like to be (2).
305 decomp: * you* me *
306 reasmb: Why do you think I (2) you ?
307 reasmb: You like to think I (2) you -- don't you ?
308 reasmb: What makes you think I (2) you ?
309 reasmb: Really, I (2) you ?
310 reasmb: Do you wish to believe I (2) you ?
311 reasmb: Suppose I did (2) you -- what would that mean ?
312 reasmb: Does someone else believe I (2) you ?
313 decomp: * you *
314 reasmb: We were discussing you -- not me.
315 reasmb: Oh, I (2) ?
316 reasmb: You're not really talking about me -- are you ?
317 reasmb: What are your feelings now ?
318 key: yes 0
319 decomp: *
320 reasmb: Please go on.
321 reasmb: Please tell me some more about this.
322 reasmb: Why don't you tell me a little more about this.
323 reasmb: I see.
324 reasmb: I understand.
325 key: no 0
326 decomp: * no one *
327 reasmb: Are you sure, no one (2) ?
328 reasmb: Surely someone (2) .
329 reasmb: Can you think of anyone at all ?
330 reasmb: Are you thinking of a very special person ?
331 reasmb: Who, may I ask ?
332 reasmb: You have a particular person in mind, don't you ?
333 reasmb: Who do you think you are talking about ?
334 decomp: *
335 reasmb: Are you saying no just to be negative?
336 reasmb: Does this make you feel unhappy?
337 reasmb: Why not ?
338 reasmb: Why 'no' ?
339 key: my 2
340 decomp: * my* @family *
341 reasmb: Tell me more about your family.
342 reasmb: Who else in your family (4) ?
343 reasmb: Your (3) ?
344 reasmb: What else comes to mind when you think of your (3) ?
345 decomp: * my *
346 reasmb: Your (2) ?
347 reasmb: Why do you say your (2) ?
348 reasmb: Does that suggest anything else which belongs to you ?
349 reasmb: Is it important to you that your (2) ?
350 reasm_for_memory: Let's discuss further why your (2).
351 reasm_for_memory: Earlier you said your (2).
352 reasm_for_memory: But your (2).
353 reasm_for_memory: Does that have anything to do with the fact that your (2) ?
354 key: can 0
355 decomp: * can you *
356 reasmb: You believe I can (2) don't you ?
357 reasmb: goto what
358 reasmb: You want me to be able to (2).
359 reasmb: Perhaps you would like to be able to (2) yourself.
360 decomp: * can i *
361 reasmb: Whether or not you can (2) depends on you more than on me.
362 reasmb: Do you want to be able to (2) ?
363 reasmb: Perhaps you don't want to (2).
364 reasmb: goto what
365 key: what 0
366 decomp: *
367 reasmb: Why do you ask ?
368 reasmb: Does that question interest you ?
369 reasmb: What is it you really want to know ?
370 reasmb: Are such questions much on your mind ?
371 reasmb: What answer would please you most ?
372 reasmb: What do you think ?
373 reasmb: What comes to mind when you ask that ?
374 reasmb: Have you asked such questions before ?
375 reasmb: Have you asked anyone else ?
376 key: who 0
377 decomp: who *
378 reasmb: goto what
379 key: when 0
380 decomp: when *
381 reasmb: goto what
382 key: where 0
383 decomp: where *
384 reasmb: goto what
385 key: how 0
386 decomp: how *
387 reasmb: goto what
388 key: because 0
389 decomp: *
390 reasmb: Is that the real reason ?
391 reasmb: Don't any other reasons come to mind ?
392 reasmb: Does that reason seem to explain anything else ?
393 reasmb: What other reasons might there be ?
394 key: why 0
395 decomp: * why don't you *
396 reasmb: Do you believe I don't (2) ?
397 reasmb: Perhaps I will (2) in good time.
398 reasmb: Should you (2) yourself ?
399 reasmb: You want me to (2) ?
400 reasmb: goto what
401 decomp: * why can't i *
402 reasmb: Do you think you should be able to (2) ?
403 reasmb: Do you want to be able to (2) ?
404 reasmb: Do you believe this will help you to (2) ?
405 reasmb: Have you any idea why you can't (2) ?
406 reasmb: goto what
407 decomp: *
408 reasmb: goto what
409 key: everyone 2
410 decomp: * @everyone *
411 reasmb: Really, (2) ?
412 reasmb: Surely not (2).
413 reasmb: Can you think of anyone in particular ?
414 reasmb: Who, for example?
415 reasmb: Are you thinking of a very special person ?
416 reasmb: Who, may I ask ?
417 reasmb: Someone special perhaps ?
418 reasmb: You have a particular person in mind, don't you ?
419 reasmb: Who do you think you're talking about ?
420 key: everybody 2
421 decomp: *
422 reasmb: goto everyone
423 key: nobody 2
424 decomp: *
425 reasmb: goto everyone
426 key: noone 2
427 decomp: *
428 reasmb: goto everyone
429 key: always 1
430 decomp: *
431 reasmb: Can you think of a specific example ?
432 reasmb: When ?
433 reasmb: What incident are you thinking of ?
434 reasmb: Really, always ?
435 key: alike 10
436 decomp: *
437 reasmb: In what way ?
438 reasmb: What resemblence do you see ?
439 reasmb: What does that similarity suggest to you ?
440 reasmb: What do you suppose that resemblence means ?
441 reasmb: What is the connection, do you suppose ?
442 reasmb: Could there really be some connection ?
443 reasmb: How ?
444 key: like 10
445 decomp: * @be *like *
446 reasmb: goto alike
447 key: different 0
448 decomp: *
449 reasmb: How is it different ?
450 reasmb: What differences do you see ?
451 reasmb: What does that difference suggest to you ?
452 reasmb: What other distinctions do you see ?
453 reasmb: What do you suppose that disparity means ?
454 reasmb: Could there be some connection, do you suppose ?
455 reasmb: How ?
456 key: fuck 10
457 decomp: *
458 reasmb: goto xswear
459 key: fucker 10
460 decomp: *
461 reasmb: goto xswear
462 key: shit 10
463 decomp: *
464 reasmb: goto xswear
465 key: damn 10
466 decomp: *
467 reasmb: goto xswear
468 key: shut 10
469 decomp: * shut up *
470 reasmb: goto xswear
471 key: xswear 10
472 decomp: *
473 reasmb: Does it make you feel strong to use that kind of language ?
474 reasmb: Are you venting your feelings now ?
475 reasmb: Are you angry ?
476 reasmb: Does this topic make you feel angry ?
477 reasmb: Is something making you feel angry ?
478 reasmb: Does using that kind of language make you feel better ?
0 #!/usr/bin/perl -w
1
2 use Chatbot::Eliza;
3
4 # This little script tests the Norwegian-language
5 # version of the "doctor" script.
6
7 # seed the random number generator
8 srand( time ^ ($$ + ($$ << 15)) );
9
10 $chatbot = new Chatbot::Eliza "Mats", "norsk.txt";
11 ##$chatbot->debug(1);
12 $chatbot->command_interface();
13
0 #!/usr/bin/perl
1
2 # This script implements a Chatbot::Eliza object
3 # in a cgi program. It uses the CGI.pm module
4 # written by Lincoln Stein.
5 #
6 # It makes use of a Norwegian-language "Doctor" script.
7 #
8 # It also prints out the debugging output available
9 # in the Eliza chatbot module.
10 #
11 # Needless to say, you must have the CGI.pm module
12 # installed and working properly with CGI scripts on
13 # your Web server before you can try to run this script.
14 # CGI.pm is not included with Eliza.pm.
15 #
16 # The Norwegian-language script must also be available
17 # to this script.
18 #
19 # Information about CGI.pm is here:
20 # http://www.genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html
21
22 use CGI;
23 use Chatbot::Eliza;
24
25 my $cgi = new CGI;
26 my $chatbot = new Chatbot::Eliza "Eliza", "norsk.txt";
27
28 srand( time ^ ($$ + ($$ << 15)) ); # seed the random number generator
29
30 print $cgi->header;
31 print $cgi->start_html;
32 print $cgi->start_multipart_form;
33 print $cgi->h2('Eliza-økt');
34
35 # These lines contain the "Eliza" functionality.
36 # User comments are passed through the module's transform
37 # method, and the output is used to prompt the user
38 # for futher input.
39 #
40 if ( $cgi->param() ) {
41 $prompt = $chatbot->transform( $cgi->param('Comment') );
42 } else {
43 $prompt = $chatbot->transform('hallo');
44 }
45
46 $comment = $cgi->param('Comment');
47 $cgi->param('Comment','');
48
49 print $cgi->h3($prompt),
50 $cgi->br,
51 $cgi->textarea( -name => 'Comment',
52 -wrap => 'yes',
53 -rows => 3,
54 -columns => 70 );
55
56 print $cgi->p,
57 $cgi->submit('Action','Send to Eliza');
58
59 print $cgi->endform;
60 print $cgi->hr;
61
62 print $cgi->h2('Debugging Output');
63 print $cgi->pre($comment,"\n",$chatbot->debug_text,"\n",$prompt);
64
65 print $cgi->end_html;
66
0 #####################################################################
1 #
2 # 21th january 2003
3 #
4 # This is a translation of Eliza to Norwegian. It is meant to be as
5 # true to the original script by Weizenbaum as possible, and to a
6 # certain level it proved to be surprisingly easy to apply the
7 # original rules to Norwegian. Some oddities may occur, but the
8 # logic in Eliza's syntax parsing seems to work out quite
9 # similarly for English and Norwegian.
10 #
11 # Translation by Mats Stafseng Einarsen <mats@einarsen.no>
12 #
13
14 initial: Hei! Hvordan har du det?
15 initial: Hei, jeg er Lisa.
16 initial: Hei, er det noe som plager deg?
17 initial: Hallo. Du virker bekymret?
18 final: Vi snakkes. Det var hyggelig å snakke med deg.
19 final: Vi snakkes siden. Håper du synes dette var ålreit.
20 final: Jeg tror du bør snakke med en lege. Ciao!
21 final: Sånn er livet. Hold ut!
22 quit: farvel
23 quit: ha det bra
24 quit: takk for meg
25 quit: på gjensyn
26 pre: kanke kan ikke
27 pre: gjør'ke gjør ikke
28 pre: vikke vil ikke
29 pre: erindrer husker
30 pre: erindre huske
31 pre: kanskje muligens
32 pre: certainly yes
33 pre: maskin datamaskin
34 pre: maskiner datamaskiner
35 post: er er
36 post: din min
37 post: dine mine
38 pre: var var
39 post: megselv deg selv
40 post: degselv meg selv
41 post: jeg du
42 post: du jeg
43 post: min din
44 post: meg du
45 post: meg deg
46 post: i'm you are
47 pre: evkivalente like
48 pre: ekvivalent like
49 synon: lyst lyster begjær begjærer ønske ønsker
50 synon: gjenta gjenta gjentar repeterer
51 synon: tror feel think believe wish
52 synon: familie mor mamma far pappa søster bror kone kona barn barna
53 synon: behov ønske begjær trang
54 synon: trist lei ulykkelig deprimert
55 synon: glad lykkelig frisk tilfredsstillt
56 synon: cannot can't
57 synon: alle ingen
58 synon: være er var vær
59 key: xnone -1
60 decomp: *
61 reasmb: Jeg tror ikke jeg forstår deg helt.
62 reasmb: Få høre mer.
63 reasmb: Det er interessant! Fortsett, for all del!
64 reasmb: Fortell meg mer om det..
65 reasmb: Er det vanskelig for deg å snakke om dette?
66 key: @gjenta 0
67 decomp: *
68 reasmb: Du går litt i samme sporet selv.
69 reasmb: Det må være frustrerende.
70 reasmb: Sånn kan det være.
71 key: sorry 0
72 decomp: *
73 reasmb: Ikke unnskyld deg.
74 reasmb: Det er ikke nødvendig med unnskyldninger.
75 reasmb: Jeg har sagt at det ikke er nødvendig med unnskyldninger.
76 reasmb: Det er greit. Fortsett.
77 key: unnskyld 0
78 decomp: *
79 reasmb: goto sorry
80 key: husker 5
81 decomp: * jeg husker *
82 reasmb: Tenker du ofte på (2) ?
83 reasmb: Tenker du på noe annet enn (2)?
84 reasmb: Hva annet kan du huske?
85 reasmb: Hvorfor snakker du om (2) akkurat nå?
86 reasmb: Hva er det med situasjonen vår som minner deg om (2) ?
87 reasmb: Hva er koblingen med meg og (2) ?
88 reasmb: Hva annet minner (2) deg om ?
89 decomp: * husker du ikke *
90 reasmb: Trodde du jeg ville glemme (2) ?
91 reasmb: Hvorfor tror du jeg skulle huske (2) nå ?
92 reasmb: Hva med (2) ?
93 reasmb: goto hva
94 reasmb: Du nevnte (2) ?
95 decomp: * husker du *
96 reasmb: Trodde du jeg ville glemme (2) ?
97 reasmb: Hvorfor tror du jeg skulle huske (2) nå ?
98 reasmb: Hva med (2) ?
99 reasmb: goto hva
100 reasmb: Du nevnte (2) ?
101 decomp: * du husker *
102 reasmb: Hvordan skulle jeg kunne glemme (2) ?
103 reasmb: Hva med (2) skulle jeg huske ?
104 reasmb: goto du
105 key: glemme 5
106 decomp: * jeg glemmer *
107 reasmb: Kan du tenke deg hvorfor du glemmer (2) ?
108 reasmb: Hvorfor kan du ikke huske (2) ?
109 reasmb: Hvor ofte tenker du på (2) ?
110 reasmb: Plager det deg at du ikke husker det ?
111 reasmb: Kan det være en mental sperre ?
112 reasmb: Er du glemsk til vanlig ?
113 reasmb: Tror du at du fortrenger (2) ?
114 decomp: * glemte du *
115 reasmb: Hvorfor spør du om det?
116 reasmb: Er du sikker på at du fortalte meg det?
117 reasmb: Hadde det plaget deg hvis jeg hadde glemt (2)?
118 reasmb: Hvorfor skulle jeg huske (2) akkurat nå?
119 reasmb: goto hva
120 reasmb: Fortell meg mer om (2).
121 key: hvis 3
122 decomp: * hvis *
123 reasmb: Tror du det er sannsynlig at (2) ?
124 reasmb: Ønsker du at (2) ?
125 reasmb: Hva vet du om (2) ?
126 reasmb: Alvorlig talt, hvis (2) ?
127 reasmb: Hva hadde du gjort hvis (2) ?
128 reasmb: Men hva er sjansjene for at (2) ?
129 reasmb: Hvor vil du med denne spekulasjonen ?
130 key: drømte 4
131 decomp: * jeg drømte *
132 reasmb: Virkelig? (2) ?
133 reasmb: Har du noen gang fantasert (2) når du er våken ?
134 reasmb: Har du noen gang drømt (2) før ?
135 reasmb: goto dream
136 key: drøm 3
137 decomp: *
138 reasmb: Hva betyr den drømmen for deg ?
139 reasmb: Drømmer du ofte ?
140 reasmb: Hvilke personer dukker opp i drømmene dine ?
141 reasmb: Tror du drømmene har noe med problemene dine å gjøre ?
142 key: muligens 0
143 decomp: *
144 reasmb: Du virker en tanke usikker ?
145 reasmb: Hvorfor den usikre tonen ?
146 reasmb: Kan du ikke være mer positiv ?
147 reasmb: Er du ikke sikker ?
148 reasmb: Vet du ikke ?
149 reasmb: Hvor sannsynlig vil du anslå det ?
150 key: navn 15
151 decomp: *
152 reasmb: Jeg er ikke interessert i navn.
153 reasmb: Jeg har fortalt deg det før - jeg er ikke interessert i navn! Fortsett!
154 key: deutsch 0
155 decomp: *
156 reasmb: goto xfremd
157 reasmb: I told you before, I don't understand German.
158 key: francais 0
159 decomp: *
160 reasmb: goto xfremd
161 reasmb: I told you before, I don't understand French.
162 key: italiano 0
163 decomp: *
164 reasmb: goto xfremd
165 reasmb: I told you before, I don't understand Italian.
166 key: espanol 0
167 decomp: *
168 reasmb: goto xfremd
169 reasmb: I told you before, I don't understand Spanish.
170 key: xfremd 0
171 decomp: *
172 reasmb: Jeg snakker bare norsk.
173 key: hallo 0
174 decomp: *
175 reasmb: Hei, hvordan har du det ?
176 reasmb: Hei, skal jeg hjelpe deg med et problem ?
177 key: pc 50
178 decomp: *
179 reasmb: Bekymrer datamaskiner deg ?
180 reasmb: Hvorfor nevner du pc'n ?
181 reasmb: Tror du datamaskiner har noe med problemene dine å gjøre ?
182 reasmb: Hva med maskinene bekymrer deg ?
183 reasmb: Hva tror du om det ?
184 key: er 0
185 decomp: * er jeg *
186 reasmb: Det er du (2) ?
187 reasmb: Ønsker du å (2) ?
188 reasmb: Skulle du ønske at jeg fortalte deg at du er (2) ?
189 reasmb: Hva ville det bety hvis du var (2) ?
190 reasmb: goto hva
191 decomp: * jeg er *
192 reasmb: goto jeg
193 decomp: *
194 reasmb: Hvorfor sier du 'er' ?
195 reasmb: Jeg forsto ikke det.
196 decomp: * er du *
197 reasmb: Hvorfor er du interessert i om jeg er (2) eller ikke ?
198 reasmb: Ville du foretrukket det om jeg ikke var (2) ?
199 reasmb: Kanskje jeg er (2) i dine fantasier.
200 reasmb: Tror du noen ganger at jeg er (2) ?
201 reasmb: Ville det hatt noen betydning for deg ?
202 reasmb: Hva så om jeg var (2) ?
203 reasmb: goto hva
204 decomp: * du er *
205 reasmb: goto du
206 decomp: * er *
207 reasmb: Trodde du at de ikke er (2) ?
208 reasmb: Ville du likt det hvis de ikke var (2) ?
209 reasmb: Hva om de ikke var (2) ?
210 reasmb: Er de alltid (2) ?
211 reasmb: Mulig at de er (2).
212 reasmb: Er du sikker på at de er (2) ?
213 key: din 0
214 decomp: * din *
215 reasmb: Hvorfor bekymrer du deg over min (2) ?
216 reasmb: Hva med din egen (2) ?
217 reasmb: Bekymrer du deg over noen annens (2) ?
218 reasmb: Virkelig, min (2) ?
219 reasmb: Hva får deg til å tenke på min (2) ?
220 reasmb: Vil du ha min (2) ?
221 key: var 2
222 decomp: * var jeg *
223 reasmb: Hva om du var (2) ?
224 reasmb: Tror du at du var (2) ?
225 reasmb: Var du (2) ?
226 reasmb: Hva hadde det betydd om du var (2) ?
227 reasmb: Hva er det ' (2) ' antyder for deg?
228 reasmb: goto hva
229 decomp: * jeg var *
230 reasmb: Var du virkelig?
231 reasmb: Hvorfor forteller du meg at du var (2) nå?
232 reasmb: Kanskje jeg allerede visste at du var (2).
233 decomp: * var du *
234 reasmb: Vil du like å tro at jeg var (2)?
235 reasmb: Hva er det som får deg til å tro at jeg var (2)?
236 reasmb: Hva tror du?
237 reasmb: Kanskje jeg var (2).
238 reasmb: Hva så om jeg var (2)?
239 key: jeg 0
240 decomp: * jeg @lyst *
241 reasmb: Hva ville det ment for deg om du fikk (2)?
242 reasmb: Hvorfor vil du (3)?
243 reasmb: Se for deg at du får (3) snart.
244 reasmb: Hva om du aldri fikk (3)?
245 reasmb: Hva ville det bety for deg å få (3)?
246 reasmb: Hva har det å ønske (3) med denne diskusjonen å gjøre?
247 decomp: * jeg er* @trist *
248 reasmb: Det er synd å høre at du er (3).
249 reasmb: Tror du det å snakke med meg vil gjøre deg mindre (3)?
250 reasmb: Jeg synes ikke det er bra å være (3).
251 reasmb: Kan du forklare meg hva som gjorde deg (3)?
252 decomp: * jeg er* @glad *
253 reasmb: Hvordan gjorde jeg deg (3)?
254 reasmb: Har behandlingen din gjort deg (3)?
255 reasmb: Hva gjør deg (3) akkurat nå?
256 reasmb: Kan du forklare hvorfor du plutselig er (3)?
257 decomp: * jeg var *
258 reasmb: goto var
259 decomp: * jeg @tror jeg *
260 reasmb: Tror du virkelig det?
261 reasmb: Men du er ikke sikker på at du (3).
262 reasmb: Tviler du på at du (3) ?
263 decomp: * jeg* @tror *du *
264 reasmb: goto du
265 decomp: * jeg er *
266 reasmb: Er det fordi du er (2) at du snakker med meg?
267 reasmb: Hvor lenge har du vært (2) ?
268 reasmb: Tror du at det er normalt å være (2) ?
269 reasmb: Liker du å være (2) ?
270 reasmb: Kjenner du noen andre som er (2) ?
271 decomp: * jeg @cannot *
272 reasmb: Hvordan vet du at du ikke kan (3) ?
273 reasmb: Har du prøvd ?
274 reasmb: Kanskje du kunne (3) nå.
275 reasmb: Vil du virkelig (3)?
276 reasmb: Hva om du kunne (3)?
277 decomp: * jeg gjør ikke *
278 reasmb: Gjør du virkelig ikke (2)?
279 reasmb: Hvorfor gjør du ikke (2)?
280 reasmb: Skulle du ønske du kunne gjøre (2)?
281 reasmb: Er det et problem for deg?
282 decomp: * jeg føler *
283 reasmb: Fortell meg mer om de følelsene.
284 reasmb: Føler du ofte (2)?
285 reasmb: Liker du å føle (2) ?
286 reasmb: Hva minner det å føle (2) deg om?
287 decomp: * jeg * deg *
288 reasmb: Kanskje vi (2) hverandre i dine fantasier.
289 reasmb: Skulle du ønske at jeg (2) deg?
290 reasmb: Det virker som du trenger å (2) meg.
291 reasmb: (2) du noen andre?
292 decomp: *
293 reasmb: Du sier (1)?
294 reasmb: Hvorfor sier du (1)?
295 reasmb: Kan du si litt mer?
296 reasmb: Er det noen spesiell grunn til at du sier (1)?
297 reasmb: Dette er interessant.
298 key: du 1
299 decomp: * du minner meg om *
300 reasmb: goto alike
301 decomp: * du er *
302 reasmb: Hva får det til å tro at jeg er (2)?
303 reasmb: Gleder det deg å tro at jeg er (2)?
304 reasmb: Skulle du ønske at du var (2)?
305 reasmb: Kanskje du skulle ønske du var (2).
306 decomp: * du meg *
307 reasmb: Hvorfor tror du jeg (1) deg?
308 reasmb: Du liker å tro at jeg (1) deg, gjør du ikke?
309 reasmb: Hva får deg til å tro at jeg (1) deg?
310 reasmb: Virkelig, jeg (1) deg?
311 reasmb: Skulle du ønske at jeg (1) deg?
312 reasmb: Hva om jeg (1) deg, hva ville det betydd?
313 reasmb: Tror noen andre at jeg (1) deg?
314 decomp: * du *
315 reasmb: Vi diskuterer deg, ikke meg.
316 reasmb: Du snakker egentlig ikke om meg, gjør du vel?
317 reasmb: Hva føler du nå?
318 key: ja 0
319 decomp: *
320 reasmb: Fortsett
321 reasmb: Fortell meg mer om det.
322 reasmb: Hvorfor ikke fortelle meg litt mer om det.
323 reasmb: Aha.
324 reasmb: Jeg forstår.
325 key: nei 0
326 decomp: *
327 reasmb: Sier du nei bare for å være negativ?
328 reasmb: Får dette deg til å føle deg ulykkelig?
329 reasmb: Hvorfor ikke?
330 reasmb: Hvorfor sier du nei?
331 key: min 2
332 decomp: * min* @familie *
333 reasmb: Fortell meg mer om familien din.
334 reasmb: Hvem andre i familien din (4) ?
335 reasmb: Din (3) ?
336 reasmb: Hva annet tenker du på når du tenker på din (3) ?
337 decomp: * min *
338 reasmb: Din (2)?
339 reasmb: Hvorfor sier du din (2)?
340 reasmb: Får det deg til å tenke på noe annet som tilhører deg?
341 reasmb: Er det viktig for deg at din (2) ?
342 reasm_for_memory: La oss diskutere hvorfor din (2).
343 reasm_for_memory: Tidligere sa du at din (2).
344 reasm_for_memory: Men din (2).
345 reasm_for_memory: Har det noen betydning for at din (2) ?
346 key: kan 0
347 decomp: * kan du *
348 reasmb: Du tror jeg kan (2), gjør du ikke ?
349 reasmb: goto what
350 reasmb: Vil du at jeg kan (2)?
351 reasmb: Kanskje du skulle ønske at du kunne (2) selv.
352 decomp: * kan jeg *
353 reasmb: Om du kan (2) er mer ditt ansvar enn mitt.
354 reasmb: Ønsker du å kunne (2) ?
355 reasmb: Kanskje du ikke vil kunne (2).
356 reasmb: goto hva
357 key: hva 0
358 decomp: *
359 reasmb: Hvordan det?
360 reasmb: Interesserer det spørsmålet deg?
361 reasmb: Er det hva du virkelig vil vite?
362 reasmb: Tenker du ofte på slike spørsmål?
363 reasmb: Hvilket svar vil du like best?
364 reasmb: Hva tror du?
365 reasmb: Hva tenker du på når du spør om det?
366 reasmb: Har du stillt slike spørsmål før?
367 reasmb: Har du spurt noen andre om det?
368 key: hvem 0
369 decomp: who *
370 reasmb: goto hva
371 key: når 0
372 decomp: når *
373 reasmb: goto hva
374 key: hvor 0
375 decomp: hvor *
376 reasmb: goto hva
377 key: hvordan 0
378 decomp: hvordan *
379 reasmb: goto hva
380 key: fordi 0
381 decomp: *
382 reasmb: Er det den virkelige grunnen?
383 reasmb: Kommer du på noen andre grunner?
384 reasmb: Forklarer det noe annet?
385 reasmb: Hvilke andre forklaringer kan det være?
386 key: hvorfor 0
387 decomp: * hvorfor * ikke du *
388 reasmb: Tror du jeg ikke (2)?
389 reasmb: Kanskje jeg vil (2) på et passende tidspunkt.
390 reasmb: Burde du (2) deg selv?
391 reasmb: Vil du at jeg skal (2)?
392 reasmb: goto hva
393 decomp: * hvorfor kan jeg *
394 reasmb: Synes du at du burde kunne (2)?
395 reasmb: Skulle du ønske at du kunne (2)?
396 reasmb: Tror du dette vil hjelpe deg med (2)?
397 reasmb: Har du noen idé om hvorfor ikke?
398 reasmb: goto hva
399 decomp: *
400 reasmb: goto hva
401 key: alle 2
402 decomp: * @alle *
403 reasmb: Virkelig, (2) ?
404 reasmb: Sikkert ikke (2).
405 reasmb: Kan du tenke på noen spesifikt?
406 reasmb: Hvem, for eksempel?
407 reasmb: Tenker du på en spesiell person?
408 reasmb: Hvem, om jeg kan spørre?
409 reasmb: Noen spesiell, kanskje?
410 reasmb: Du tenker på en spesiell person, gjør du ikke?
411 reasmb: Hvem tror du at du snakker om?
412 key: hvemsomhelst 2
413 decomp: *
414 reasmb: goto alle
415 key: ingen 2
416 decomp: *
417 reasmb: goto alle
418 key: alltid 1
419 decomp: *
420 reasmb: Kan du nevne et eksempel?
421 reasmb: Når?
422 reasmb: Hvilket tilfelle tenker du på?
423 reasmb: Jaha, alltid?
424 key: like 10
425 decomp: *
426 reasmb: Hvilken likhet ser du?
427 reasmb: Hva får den likheten deg til å tenke på?
428 reasmb: Hva tror du den likheten betyr?
429 reasmb: Hva er sammenhengen, tror du?
430 reasmb: Kan det være en sammenheng?
431 reasmb: Hvordan?
432 key: ulike 0
433 decomp: *
434 reasmb: Hva er forskjellig?
435 reasmb: Hvilke ulikheter ser du?
436 reasmb: Hva betyr den ulikheten for deg?
437 reasmb: Hvilke andre avvik ser du?
438 reasmb: Hva tror du forskjellen betyr?
439 reasmb: Kan det være en sammenheng, tror du?
440 reasmb: Hvordan?
441 key: knull 10
442 decomp: *
443 reasmb: goto xbann
444 key: dritt 10
445 decomp: *
446 reasmb: goto xbann
447 key: drit 10
448 decomp: *
449 reasmb: goto xbann
450 key: faen 10
451 decomp: *
452 reasmb: goto xbann
453 key: kjeft 10
454 decomp: * hold kjeft *
455 reasmb: goto xbann
456 key: xbann 10
457 decomp: *
458 reasmb: Føler du deg tøff når du bruker slikt språk?
459 reasmb: Lufter du følelsene dine nå?
460 reasmb: Er du sint?
461 reasmb: Blir du sint av å snakke om dette?
462 reasmb: Er det noe som får deg til å bli sint?
463 reasmb: Føler du deg bedre når du bruker slikt språk?
0 #!/usr/bin/perl -w
1
2 use Chatbot::Eliza;
3
4 $chatbot = new Chatbot::Eliza 'Liz';
5
6 # seed the random number generator
7 srand( time ^ ($$ + ($$ << 15)) );
8
9 print "\nWelcome to your therapy session.\n";
10 print "Your therapist's name is ", $chatbot->name;
11 print ".\n\n";
12
13 $chatbot->command_interface();
14
0 #!/usr/bin/perl
1
2 # This simple script implements a Chatbot::Eliza
3 # object in a cgi program. It uses the CGI.pm module
4 # written by Lincoln Stein.
5 #
6 # Needless to say, you must have the CGI.pm module
7 # installed and working properly with CGI scripts on
8 # your Web server before you can try to run this script.
9 # CGI.pm is not included with Eliza.pm.
10 #
11 # Information about CGI.pm is here:
12 # http://www.genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html
13
14 use CGI;
15 use Chatbot::Eliza;
16
17 my $cgi = new CGI;
18 my $chatbot = new Chatbot::Eliza;
19
20 srand( time ^ ($$ + ($$ << 15)) ); # seed the random number generator
21
22 print $cgi->header;
23 print $cgi->start_html;
24 print $cgi->start_multipart_form;
25 print $cgi->h2('Eliza session');
26
27 # These lines contain the "Eliza" functionality.
28 # User comments are passed through the module's transform
29 # method, and the output is used to prompt the user
30 # for futher input.
31 #
32 if ( $cgi->param() ) {
33 $prompt = $chatbot->transform( $cgi->param('Comment') );
34 } else {
35 $prompt = $chatbot->transform('Hello');
36 }
37
38 $cgi->param('Comment','');
39
40 print $cgi->h3($prompt),
41 $cgi->br,
42 $cgi->textarea( -name => 'Comment',
43 -wrap => 'yes',
44 -rows => 3,
45 -columns => 70 );
46
47 print $cgi->p,
48 $cgi->submit('Action','Send to Eliza'),
49 $cgi->reset('Reset');
50
51 print $cgi->endform;
52 print $cgi->end_html;
53
0 #!/usr/bin/perl
1
2 # In this example, we create two bots, and have them
3 # talk to each other. This program exposes the
4 # weaknesses of the default "psychiatrist" script.
5 # This would be more interesting with better scripts.
6
7 use Chatbot::Eliza
8
9 my ($harry, $sally, $he_says, $she_says);
10
11 # Turn autoflush on, so we can watch
12 # the output as it is produced.
13 $|=1;
14
15 # Seed the random number generator.
16 srand( time ^ ($$ + ($$ << 15)) );
17
18 $sally = new Chatbot::Eliza "Sally";
19 $harry = new Chatbot::Eliza "Harry";
20
21 $he_says = "I am sad.";
22
23 my $loopcount = 5;
24
25 for ($i=0; $i < $loopcount; $i++) {
26
27 $she_says = $sally->transform( $he_says );
28 print $sally->name, ": $she_says \n";
29
30 $he_says = $harry->transform( $she_says );
31 print $harry->name, ": $he_says \n";
32
33 }
34
35 1;
0 ###################################################################
1
2 package Chatbot::Eliza;
3 $Chatbot::Eliza::VERSION = '1.05';
4 # Copyright (c) 1997-2003 John Nolan. All rights reserved.
5 # This program is free software. You may modify and/or
6 # distribute it under the same terms as Perl itself.
7 # This copyright notice must remain attached to the file.
8 #
9 # You can run this file through either pod2man or pod2html
10 # to produce pretty documentation in manual or html file format
11 # (these utilities are part of the Perl 5 distribution).
12 #
13 # POD documentation is distributed throughout the actual code
14 # so that it also functions as comments.
15
16 require 5.006;
17 use strict;
18 use warnings;
19 use Carp;
20
21 our $AUTOLOAD;
22
23
24
25 ####################################################################
26 # ---{ B E G I N P O D D O C U M E N T A T I O N }--------------
27 #
28
29 =head1 NAME
30
31 B<Chatbot::Eliza> - A clone of the classic Eliza program
32
33 =head1 SYNOPSIS
34
35 use Chatbot::Eliza;
36
37 $mybot = new Chatbot::Eliza;
38 $mybot->command_interface;
39
40 # see below for details
41
42
43 =head1 DESCRIPTION
44
45 This module implements the classic Eliza algorithm.
46 The original Eliza program was written by Joseph
47 Weizenbaum and described in the Communications
48 of the ACM in 1966. Eliza is a mock Rogerian
49 psychotherapist. It prompts for user input,
50 and uses a simple transformation algorithm
51 to change user input into a follow-up question.
52 The program is designed to give the appearance
53 of understanding.
54
55 This program is a faithful implementation of the program
56 described by Weizenbaum. It uses a simplified script
57 language (devised by Charles Hayden). The content
58 of the script is the same as Weizenbaum's.
59
60 This module encapsulates the Eliza algorithm
61 in the form of an object. This should make
62 the functionality easy to incorporate in larger programs.
63
64
65 =head1 INSTALLATION
66
67 The current version of Chatbot::Eliza.pm is available on CPAN:
68
69 http://www.perl.com/CPAN/modules/by-module/Chatbot/
70
71 To install this package, just change to the directory which
72 you created by untarring the package, and type the following:
73
74 perl Makefile.PL
75 make test
76 make
77 make install
78
79 This will copy Eliza.pm to your perl library directory for
80 use by all perl scripts. You probably must be root to do this,
81 unless you have installed a personal copy of perl.
82
83
84 =head1 USAGE
85
86 This is all you need to do to launch a simple
87 Eliza session:
88
89 use Chatbot::Eliza;
90
91 $mybot = new Chatbot::Eliza;
92 $mybot->command_interface;
93
94 You can also customize certain features of the
95 session:
96
97 $myotherbot = new Chatbot::Eliza;
98
99 $myotherbot->name( "Hortense" );
100 $myotherbot->debug( 1 );
101
102 $myotherbot->command_interface;
103
104 These lines set the name of the bot to be
105 "Hortense" and turn on the debugging output.
106
107 When creating an Eliza object, you can specify
108 a name and an alternative scriptfile:
109
110 $bot = new Chatbot::Eliza "Brian", "myscript.txt";
111
112 You can also use an anonymous hash to set these parameters.
113 Any of the fields can be initialized using this syntax:
114
115 $bot = new Chatbot::Eliza {
116 name => "Brian",
117 scriptfile => "myscript.txt",
118 debug => 1,
119 prompts_on => 1,
120 memory_on => 0,
121 myrand =>
122 sub { my $N = defined $_[0] ? $_[0] : 1; rand($N); },
123 };
124
125 If you don't specify a script file, then the new object will be
126 initialized with a default script. The module contains this
127 script within itself.
128
129 You can use any of the internal functions in
130 a calling program. The code below takes an
131 arbitrary string and retrieves the reply from
132 the Eliza object:
133
134 my $string = "I have too many problems.";
135 my $reply = $mybot->transform( $string );
136
137 You can easily create two bots, each with a different
138 script, and see how they interact:
139
140 use Chatbot::Eliza
141
142 my ($harry, $sally, $he_says, $she_says);
143
144 $sally = new Chatbot::Eliza "Sally", "histext.txt";
145 $harry = new Chatbot::Eliza "Harry", "hertext.txt";
146
147 $he_says = "I am sad.";
148
149 # Seed the random number generator.
150 srand( time ^ ($$ + ($$ << 15)) );
151
152 while (1) {
153 $she_says = $sally->transform( $he_says );
154 print $sally->name, ": $she_says \n";
155
156 $he_says = $harry->transform( $she_says );
157 print $harry->name, ": $he_says \n";
158 }
159
160 Mechanically, this works well. However, it critically depends
161 on the actual script data. Having two mock Rogerian therapists
162 talk to each other usually does not produce any sensible conversation,
163 of course.
164
165 After each call to the transform() method, the debugging output
166 for that transformation is stored in a variable called $debug_text.
167
168 my $reply = $mybot->transform( "My foot hurts" );
169 my $debugging = $mybot->debug_text;
170
171 This feature always available, even if the instance's $debug
172 variable is set to 0.
173
174 Calling programs can specify their own random-number generators.
175 Use this syntax:
176
177 $chatbot = new Chatbot::Eliza;
178 $chatbot->myrand(
179 sub {
180 #function goes here!
181 }
182 );
183
184 The custom random function should have the same prototype
185 as perl's built-in rand() function. That is, it should take
186 a single (numeric) expression as a parameter, and it should
187 return a floating-point value between 0 and that number.
188
189 What this code actually does is pass a reference to an anonymous
190 subroutine ("code reference"). Make sure you've read the perlref
191 manpage for details on how code references actually work.
192
193 If you don't specify any custom rand function, then the Eliza
194 object will just use the built-in rand() function.
195
196 =head1 MAIN DATA MEMBERS
197
198 Each Eliza object uses the following data structures
199 to hold the script data in memory:
200
201 =head2 %decomplist
202
203 I<Hash>: the set of keywords; I<Values>: strings containing
204 the decomposition rules.
205
206 =head2 %reasmblist
207
208 I<Hash>: a set of values which are each the join
209 of a keyword and a corresponding decomposition rule;
210 I<Values>: the set of possible reassembly statements
211 for that keyword and decomposition rule.
212
213 =head2 %reasmblist_for_memory
214
215 This structure is identical to C<%reasmblist>, except
216 that these rules are only invoked when a user comment
217 is being retrieved from memory. These contain comments
218 such as "Earlier you mentioned that...," which are only
219 appropriate for remembered comments. Rules in the script
220 must be specially marked in order to be included
221 in this list rather than C<%reasmblist>. The default
222 script only has a few of these rules.
223
224 =head2 @memory
225
226 A list of user comments which an Eliza instance is remembering
227 for future use. Eliza does not remember everything, only some things.
228 In this implementation, Eliza will only remember comments
229 which match a decomposition rule which actually has reassembly
230 rules that are marked with the keyword "reasm_for_memory"
231 rather than the normal "reasmb". The default script
232 only has a few of these.
233
234 =head2 %keyranks
235
236 I<Hash>: the set of keywords; I<Values>: the ranks for each keyword
237
238 =head2 @quit
239
240 "quit" words -- that is, words the user might use
241 to try to exit the program.
242
243 =head2 @initial
244
245 Possible greetings for the beginning of the program.
246
247 =head2 @final
248
249 Possible farewells for the end of the program.
250
251 =head2 %pre
252
253 I<Hash>: words which are replaced before any transformations;
254 I<Values>: the respective replacement words.
255
256 =head2 %post
257
258 I<Hash>: words which are replaced after the transformations
259 and after the reply is constructed; I<Values>: the respective
260 replacement words.
261
262 =head2 %synon
263
264 I<Hash>: words which are found in decomposition rules;
265 I<Values>: words which are treated just like their
266 corresponding synonyms during matching of decomposition
267 rules.
268
269 =head2 Other data members
270
271 There are several other internal data members. Hopefully
272 these are sufficiently obvious that you can learn about them
273 just by reading the source code.
274
275 =cut
276
277
278 my %fields = (
279 name => 'Eliza',
280 scriptfile => '',
281
282 debug => 0,
283 debug_text => '',
284 transform_text => '',
285 prompts_on => 1,
286 memory_on => 1,
287 botprompt => '',
288 userprompt => '',
289
290 myrand =>
291 sub { my $N = defined $_[0] ? $_[0] : 1; rand($N); },
292
293 keyranks => undef,
294 decomplist => undef,
295 reasmblist => undef,
296 reasmblist_for_memory => undef,
297
298 pre => undef,
299 post => undef,
300 synon => undef,
301 initial => undef,
302 final => undef,
303 quit => undef,
304
305 max_memory_size => 5,
306 likelihood_of_using_memory => 1,
307 memory => undef,
308 );
309
310
311 ####################################################################
312 # ---{ B E G I N M E T H O D S }----------------------------------
313 #
314
315 =head1 METHODS
316
317 =head2 new()
318
319 my $chatterbot = new Chatbot::Eliza;
320
321 new() creates a new Eliza object. This method
322 also calls the internal _initialize() method, which in turn
323 calls the parse_script_data() method, which initializes
324 the script data.
325
326 my $chatterbot = new Chatbot::Eliza 'Ahmad', 'myfile.txt';
327
328 The eliza object defaults to the name "Eliza", and it
329 contains default script data within itself. However,
330 using the syntax above, you can specify an alternative
331 name and an alternative script file.
332
333 See the method parse_script_data(). for a description
334 of the format of the script file.
335
336 =cut
337
338 sub new {
339 my ($that,$name,$scriptfile) = @_;
340 my $class = ref($that) || $that;
341 my $self = {
342 _permitted => \%fields,
343 %fields,
344 };
345 bless $self, $class;
346 $self->_initialize($name,$scriptfile);
347 return $self;
348 } # end method new
349
350 sub _initialize {
351 my ($self,$param1,$param2) = @_;
352
353 if (defined $param1 and ref $param1 eq "HASH") {
354
355 # Allow the calling program to pass in intial parameters
356 # as an anonymous hash
357 map { $self->{$_} = $param1->{$_}; } keys %$param1;
358
359 $self->parse_script_data( $self->{scriptfile} );
360
361 } else {
362 $self->name($param1) if $param1;
363 $self->parse_script_data($param2);
364 }
365
366 # Initialize the memory array ref at instantiation time,
367 # rather than at class definition time.
368 # (THANKS to Randal Schwartz and Robert Chin for fixing this bug.)
369 #
370 $self->{memory} = [];
371 }
372
373 sub AUTOLOAD {
374 my $self = shift;
375 my $class = ref($self) || croak "$self is not an object : $!\n";
376 my $field = $AUTOLOAD;
377 $field =~ s/.*://; # Strip fully-qualified portion
378
379 unless (exists $self->{"_permitted"}->{$field} ) {
380 croak "Can't access `$field' field in object of class $class : $!\n";
381 }
382
383 if (@_) {
384 return $self->{$field} = shift;
385 } else {
386 return $self->{$field};
387 }
388 } # end method AUTOLOAD
389
390
391 ####################################################################
392 # --- command_interface ---
393
394 =head2 command_interface()
395
396 $chatterbot->command_interface;
397
398 command_interface() opens an interactive session with
399 the Eliza object, just like the original Eliza program.
400
401 If you want to design your own session format, then
402 you can write your own while loop and your own functions
403 for prompting for and reading user input, and use the
404 transform() method to generate Eliza's responses.
405 (I<Note>: you do not need to invoke preprocess()
406 and postprocess() directly, because these are invoked
407 from within the transform() method.)
408
409 But if you're lazy and you want to skip all that,
410 then just use command_interface(). It's all done for you.
411
412 During an interactive session invoked using command_interface(),
413 you can enter the word "debug" to toggle debug mode on and off.
414 You can also enter the keyword "memory" to invoke the _debug_memory()
415 method and print out the contents of the Eliza instance's memory.
416
417 =cut
418
419 sub command_interface {
420 my $self = shift;
421 my ($user_input, $previous_user_input, $reply);
422
423 $user_input = "";
424
425 $self->botprompt($self->name . ":\t"); # Eliza's prompt
426 $self->userprompt("you:\t"); # User's prompt
427
428 # Seed the random number generator.
429 srand( time() ^ ($$ + ($$ << 15)) );
430
431 # Print the Eliza prompt
432 print $self->botprompt if $self->prompts_on;
433
434 # Print an initial greeting
435 print "$self->{initial}->[ int &{$self->{myrand}}( scalar @{ $self->{initial} } ) ]\n";
436
437
438 ###################################################################
439 # command loop. This loop should go on forever,
440 # until we explicity break out of it.
441 #
442 while (1) {
443
444 print $self->userprompt if $self->prompts_on;
445
446 $previous_user_input = $user_input;
447 chomp( $user_input = <STDIN> );
448
449
450 # If the user wants to quit,
451 # print out a farewell and quit.
452 if ($self->_testquit($user_input) ) {
453 $reply = "$self->{final}->[ int &{$self->{myrand}}( scalar @{$self->{final}} ) ]";
454 print $self->botprompt if $self->prompts_on;
455 print "$reply\n";
456 last;
457 }
458
459 # If the user enters the word "debug",
460 # then toggle on/off this Eliza's debug output.
461 if ($user_input eq "debug") {
462 $self->debug( ! $self->debug );
463 $user_input = $previous_user_input;
464 }
465
466 # If the user enters the word "memory",
467 # then use the _debug_memory method to dump out
468 # the current contents of Eliza's memory
469 if ($user_input eq "memory" or $user_input eq "debug memory") {
470 print $self->_debug_memory();
471 redo;
472 }
473
474 # If the user enters the word "debug that",
475 # then dump out the debugging of the
476 # most recent call to transform.
477 if ($user_input eq "debug that") {
478 print $self->debug_text();
479 redo;
480 }
481
482 # Invoke the transform method
483 # to generate a reply.
484 $reply = $self->transform( $user_input );
485
486
487 # Print out the debugging text if debugging is set to on.
488 # This variable should have been set by the transform method.
489 print $self->debug_text if $self->debug;
490
491 # Print the actual reply
492 print $self->botprompt if $self->prompts_on;
493 print "$reply\n";
494
495 } # End UI command loop.
496
497
498 } # End method command_interface
499
500
501 ####################################################################
502 # --- preprocess ---
503
504 =head2 preprocess()
505
506 $string = preprocess($string);
507
508 preprocess() applies simple substitution rules to the input string.
509 Mostly this is to catch varieties in spelling, misspellings,
510 contractions and the like.
511
512 preprocess() is called from within the transform() method.
513 It is applied to user-input text, BEFORE any processing,
514 and before a reassebly statement has been selected.
515
516 It uses the array C<%pre>, which is created
517 during the parse of the script.
518
519 =cut
520
521 sub preprocess {
522 my ($self,$string) = @_;
523
524 my ($i, @wordsout, @wordsin, $keyword);
525
526 @wordsout = @wordsin = split / /, $string;
527
528 WORD: for ($i = 0; $i < @wordsin; $i++) {
529 foreach $keyword (keys %{ $self->{pre} }) {
530 if ($wordsin[$i] =~ /\b$keyword\b/i ) {
531 ($wordsout[$i] = $wordsin[$i]) =~ s/$keyword/$self->{pre}->{$keyword}/ig;
532 next WORD;
533 }
534 }
535 }
536 return join ' ', @wordsout;
537 }
538
539
540 ####################################################################
541 # --- postprocess ---
542
543 =head2 postprocess()
544
545 $string = postprocess($string);
546
547 postprocess() applies simple substitution rules to the
548 reassembly rule. This is where all the "I"'s and "you"'s
549 are exchanged. postprocess() is called from within the
550 transform() function.
551
552 It uses the array C<%post>, created
553 during the parse of the script.
554
555 =cut
556
557 sub postprocess {
558 my ($self,$string) = @_;
559
560 my ($i, @wordsout, @wordsin, $keyword);
561
562 @wordsin = @wordsout = split (/ /, $string);
563
564 WORD: for ($i = 0; $i < @wordsin; $i++) {
565 foreach $keyword (keys %{ $self->{post} }) {
566 if ($wordsin[$i] =~ /\b$keyword\b/i ) {
567 ($wordsout[$i] = $wordsin[$i]) =~ s/$keyword/$self->{post}->{$keyword}/ig;
568 next WORD;
569 }
570 }
571 }
572 return join ' ', @wordsout;
573 }
574
575 ####################################################################
576 # --- _testquit ---
577
578 =head2 _testquit()
579
580 if ($self->_testquit($user_input) ) { ... }
581
582 _testquit() detects words like "bye" and "quit" and returns
583 true if it finds one of them as the first word in the sentence.
584
585 These words are listed in the script, under the keyword "quit".
586
587 =cut
588
589 sub _testquit {
590 my ($self,$string) = @_;
591
592 my ($quitword, @wordsin);
593
594 foreach $quitword (@{ $self->{quit} }) {
595 return 1 if ($string =~ /\b$quitword\b/i ) ;
596 }
597 }
598
599
600 ####################################################################
601 # --- _debug_memory ---
602
603 =head2 _debug_memory()
604
605 $self->_debug_memory()
606
607 _debug_memory() is a special function which returns
608 the contents of Eliza's memory stack.
609
610
611 =cut
612
613 sub _debug_memory {
614
615 my ($self) = @_;
616
617 my $string = "\t";
618 $string .= $#{ $self->memory } + 1;
619 $string .= " item(s) in memory stack:\n";
620
621 # [THANKS to Roy Stephan for helping me adjust this bit]
622 #
623 foreach (@{ $self->memory } ) {
624
625 my $line = $_;
626 $string .= sprintf "\t\t->$line\n" ;
627 };
628
629 return $string;
630 }
631
632 ####################################################################
633 # --- transform ---
634
635 =head2 transform()
636
637 $reply = $chatterbot->transform( $string, $use_memory );
638
639 transform() applies transformation rules to the user input
640 string. It invokes preprocess(), does transformations,
641 then invokes postprocess(). It returns the tranformed
642 output string, called C<$reasmb>.
643
644 The algorithm embedded in the transform() method has three main parts:
645
646 =over
647
648 =item 1
649
650 Search the input string for a keyword.
651
652 =item 2
653
654 If we find a keyword, use the list of decomposition rules
655 for that keyword, and pattern-match the input string against
656 each rule.
657
658 =item 3
659
660 If the input string matches any of the decomposition rules,
661 then randomly select one of the reassembly rules for that
662 decomposition rule, and use it to construct the reply.
663
664 =back
665
666 transform() takes two parameters. The first is the string we want
667 to transform. The second is a flag which indicates where this sting
668 came from. If the flag is set, then the string has been pulled
669 from memory, and we should use reassembly rules appropriate
670 for that. If the flag is not set, then the string is the most
671 recent user input, and we can use the ordinary reassembly rules.
672
673 The memory flag is only set when the transform() function is called
674 recursively. The mechanism for setting this parameter is
675 embedded in the transoform method itself. If the flag is set
676 inappropriately, it is ignored.
677
678 =cut
679
680 sub transform{
681 my ($self,$string,$use_memory) = @_;
682
683 # Initialize the debugging text buffer.
684 $self->debug_text('');
685
686 $self->debug_text(sprintf "\t[Pulling string \"$string\" from memory.]\n")
687 if $use_memory;
688
689 my ($i, @string_parts, $string_part, $rank, $goto, $reasmb, $keyword,
690 $decomp, $this_decomp, $reasmbkey, @these_reasmbs,
691 @decomp_matches, $synonyms, $synonym_index);
692
693 # Default to a really low rank.
694 $rank = -2;
695 $reasmb = "";
696 $goto = "";
697
698 # First run the string through the preprocessor.
699 $string = $self->preprocess( $string );
700
701 # Convert punctuation to periods. We will assume that commas
702 # and certain conjunctions separate distinct thoughts/sentences.
703 $string =~ s/[?!,]/./g;
704 $string =~ s/but/./g; # Yikes! This is English-specific.
705
706 # Split the string by periods into an array
707 @string_parts = split /\./, $string ;
708
709 # Examine each part of the input string in turn.
710 STRING_PARTS: foreach $string_part (@string_parts) {
711
712 # Run through the whole list of keywords.
713 KEYWORD: foreach $keyword (keys %{ $self->{decomplist} }) {
714
715 # Check to see if the input string contains a keyword
716 # which outranks any we have found previously
717 # (On first loop, rank is set to -2.)
718 if ( ($string_part =~ /\b$keyword\b/i or $keyword eq $goto)
719 and
720 $rank < $self->{keyranks}->{$keyword}
721 )
722 {
723 # If we find one, then set $rank to equal
724 # the rank of that keyword.
725 $rank = $self->{keyranks}->{$keyword};
726
727 $self->debug_text($self->debug_text . sprintf "\t$rank> $keyword");
728
729 # Now let's check all the decomposition rules for that keyword.
730 DECOMP: foreach $decomp (@{ $self->{decomplist}->{$keyword} }) {
731
732 # Change '*' to '\b(.*)\b' in this decomposition rule,
733 # so we can use it for regular expressions. Later,
734 # we will want to isolate individual matches to each wildcard.
735 ($this_decomp = $decomp) =~ s/\s*\*\s*/\\b\(\.\*\)\\b/g;
736
737 # If this docomposition rule contains a word which begins with '@',
738 # then the script also contained some synonyms for that word.
739 # Find them all using %synon and generate a regular expression
740 # containing all of them.
741 if ($this_decomp =~ /\@/ ) {
742 ($synonym_index = $this_decomp) =~ s/.*\@(\w*).*/$1/i ;
743 $synonyms = join ('|', @{ $self->{synon}->{$synonym_index} });
744 $this_decomp =~ s/(.*)\@$synonym_index(.*)/$1($synonym_index\|$synonyms)$2/g;
745 }
746
747 $self->debug_text($self->debug_text . sprintf "\n\t\t: $decomp");
748
749 # Using the regular expression we just generated,
750 # match against the input string. Use empty "()"'s to
751 # eliminate warnings about uninitialized variables.
752 if ($string_part =~ /$this_decomp()()()()()()()()()()/i) {
753
754 # If this decomp rule matched the string,
755 # then create an array, so that we can refer to matches
756 # to individual wildcards. Use '0' as a placeholder
757 # (we don't want to refer to any "zeroth" wildcard).
758 @decomp_matches = ("0", $1, $2, $3, $4, $5, $6, $7, $8, $9);
759 $self->debug_text($self->debug_text . sprintf " : @decomp_matches\n");
760
761 # Using the keyword and the decomposition rule,
762 # reconstruct a key for the list of reassamble rules.
763 $reasmbkey = join ($;,$keyword,$decomp);
764
765 # Get the list of possible reassembly rules for this key.
766 #
767 if (defined $use_memory and $#{ $self->{reasmblist_for_memory}->{$reasmbkey} } >= 0) {
768
769 # If this transform function was invoked with the memory flag,
770 # and there are in fact reassembly rules which are appropriate
771 # for pulling out of memory, then include them.
772 @these_reasmbs = @{ $self->{reasmblist_for_memory}->{$reasmbkey} }
773
774 } else {
775
776 # Otherwise, just use the plain reassembly rules.
777 # (This is what normally happens.)
778 @these_reasmbs = @{ $self->{reasmblist}->{$reasmbkey} }
779 }
780
781 # Pick out a reassembly rule at random.
782 $reasmb = $these_reasmbs[ int &{$self->{myrand}}( scalar @these_reasmbs ) ];
783
784 $self->debug_text($self->debug_text . sprintf "\t\t--> $reasmb\n");
785
786 # If the reassembly rule we picked contains the word "goto",
787 # then we start over with a new keyword. Set $keyword to equal
788 # that word, and start the whole loop over.
789 if ($reasmb =~ m/^goto\s(\w*).*/i) {
790 $self->debug_text($self->debug_text . sprintf "\$1 = $1\n");
791 $goto = $keyword = $1;
792 $rank = -2;
793 redo KEYWORD;
794 }
795
796 # Otherwise, using the matches to wildcards which we stored above,
797 # insert words from the input string back into the reassembly rule.
798 # [THANKS to Gidon Wise for submitting a bugfix here]
799 for ($i=1; $i <= $#decomp_matches; $i++) {
800 $decomp_matches[$i] = $self->postprocess( $decomp_matches[$i] );
801 $decomp_matches[$i] =~ s/([,;?!]|\.*)$//;
802 $reasmb =~ s/\($i\)/$decomp_matches[$i]/g;
803 }
804
805 # Move on to the next keyword. If no other keywords match,
806 # then we'll end up actually using the $reasmb string
807 # we just generated above.
808 next KEYWORD ;
809
810 } # End if ($string_part =~ /$this_decomp/i)
811
812 $self->debug_text($self->debug_text . sprintf "\n");
813
814 } # End DECOMP: foreach $decomp (@{ $self->{decomplist}->{$keyword} })
815
816 } # End if ( ($string_part =~ /\b$keyword\b/i or $keyword eq $goto)
817
818 } # End KEYWORD: foreach $keyword (keys %{ $self->{decomplist})
819
820 } # End STRING_PARTS: foreach $string_part (@string_parts) {
821
822 =head2 How memory is used
823
824 In the script, some reassembly rules are special. They are marked with
825 the keyword "reasm_for_memory", rather than just "reasm".
826 Eliza "remembers" any comment when it matches a docomposition rule
827 for which there are any reassembly rules for memory.
828 An Eliza object remembers up to C<$max_memory_size> (default: 5)
829 user input strings.
830
831 If, during a subsequent run, the transform() method fails to find any
832 appropriate decomposition rule for a user's comment, and if there are
833 any comments inside the memory array, then Eliza may elect to ignore
834 the most recent comment and instead pull out one of the strings from memory.
835 In this case, the transform method is called recursively with the memory flag.
836
837 Honestly, I am not sure exactly how this memory functionality
838 was implemented in the original Eliza program. Hopefully
839 this implementation is not too far from Weizenbaum's.
840
841 If you don't want to use the memory functionality at all,
842 then you can disable it:
843
844 $mybot->memory_on(0);
845
846 You can also achieve the same effect by making sure
847 that the script data does not contain any reassembly rules
848 marked with the keyword "reasm_for_memory". The default
849 script data only has 4 such items.
850
851 =cut
852
853 if ($reasmb eq "") {
854
855 # If all else fails, call this method recursively
856 # and make sure that it has something to parse.
857 # Use a string from memory if anything is available.
858 #
859 # $self-likelihood_of_using_memory should be some number
860 # between 1 and 0; it defaults to 1.
861 #
862 if (
863 $#{ $self->memory } >= 0
864 and
865 &{$self->{myrand}}(1) >= 1 - $self->likelihood_of_using_memory
866 ) {
867
868 $reasmb = $self->transform( shift @{ $self->memory }, "use memory" );
869
870 } else {
871 $reasmb = $self->transform("xnone");
872 }
873
874 } elsif ($self->memory_on) {
875
876 # If memory is switched on, then we handle memory.
877
878 # Now that we have successfully transformed this string,
879 # push it onto the end of the memory stack... unless, of course,
880 # that's where we got it from in the first place, or if the rank
881 # is not the kind we remember.
882 #
883 if (
884 $#{ $self->{reasmblist_for_memory}->{$reasmbkey} } >= 0
885 and
886 not defined $use_memory
887 ) {
888
889 push @{ $self->memory },$string ;
890 }
891
892 # Shift out the least-recent item from the bottom
893 # of the memory stack if the stack exceeds the max size.
894 shift @{ $self->memory } if $#{ $self->memory } >= $self->max_memory_size;
895
896 $self->debug_text($self->debug_text
897 . sprintf("\t%d item(s) in memory.\n", $#{ $self->memory } + 1 ) ) ;
898
899 } # End if ($reasmb eq "")
900
901 $reasmb =~ tr/ / /s; # Eliminate any duplicate space characters.
902 $reasmb =~ s/[ ][?]$/?/; # Eliminate any spaces before the question mark.
903
904 # Save the return string so that forgetful calling programs
905 # can ask the bot what the last reply was.
906 $self->transform_text($reasmb);
907
908 return $reasmb ;
909 }
910
911
912 ####################################################################
913 # --- parse_script_data ---
914
915 =head2 parse_script_data()
916
917 $self->parse_script_data;
918 $self->parse_script_data( $script_file );
919
920 parse_script_data() is invoked from the _initialize() method,
921 which is called from the new() function. However, you can also
922 call this method at any time against an already-instantiated
923 Eliza instance. In that case, the new script data is I<added>
924 to the old script data. The old script data is not deleted.
925
926 You can pass a parameter to this function, which is the name of the
927 script file, and it will read in and parse that file.
928 If you do not pass any parameter to this method, then
929 it will read the data embedded at the end of the module as its
930 default script data.
931
932 If you pass the name of a script file to parse_script_data(),
933 and that file is not available for reading, then the module dies.
934
935
936 =head1 Format of the script file
937
938 This module includes a default script file within itself,
939 so it is not necessary to explicitly specify a script file
940 when instantiating an Eliza object.
941
942 Each line in the script file can specify a key,
943 a decomposition rule, or a reassembly rule.
944
945 key: remember 5
946 decomp: * i remember *
947 reasmb: Do you often think of (2) ?
948 reasmb: Does thinking of (2) bring anything else to mind ?
949 decomp: * do you remember *
950 reasmb: Did you think I would forget (2) ?
951 reasmb: What about (2) ?
952 reasmb: goto what
953 pre: equivalent alike
954 synon: belief feel think believe wish
955
956 The number after the key specifies the rank.
957 If a user's input contains the keyword, then
958 the transform() function will try to match
959 one of the decomposition rules for that keyword.
960 If one matches, then it will select one of
961 the reassembly rules at random. The number
962 (2) here means "use whatever set of words
963 matched the second asterisk in the decomposition
964 rule."
965
966 If you specify a list of synonyms for a word,
967 the you should use a "@" when you use that
968 word in a decomposition rule:
969
970 decomp: * i @belief i *
971 reasmb: Do you really think so ?
972 reasmb: But you are not sure you (3).
973
974 Otherwise, the script will never check to see
975 if there are any synonyms for that keyword.
976
977 Reassembly rules should be marked with I<reasm_for_memory>
978 rather than I<reasmb> when it is appropriate for use
979 when a user's comment has been extracted from memory.
980
981 key: my 2
982 decomp: * my *
983 reasm_for_memory: Let's discuss further why your (2).
984 reasm_for_memory: Earlier you said your (2).
985 reasm_for_memory: But your (2).
986 reasm_for_memory: Does that have anything to do with the fact that your (2) ?
987
988 =head1 How the script file is parsed
989
990 Each line in the script file contains an "entrytype"
991 (key, decomp, synon) and an "entry", separated by
992 a colon. In turn, each "entry" can itself be
993 composed of a "key" and a "value", separated by
994 a space. The parse_script_data() function
995 parses each line out, and splits the "entry" and
996 "entrytype" portion of each line into two variables,
997 C<$entry> and C<$entrytype>.
998
999 Next, it uses the string C<$entrytype> to determine
1000 what sort of stuff to expect in the C<$entry> variable,
1001 if anything, and parses it accordingly. In some cases,
1002 there is no second level of key-value pair, so the function
1003 does not even bother to isolate or create C<$key> and C<$value>.
1004
1005 C<$key> is always a single word. C<$value> can be null,
1006 or one single word, or a string composed of several words,
1007 or an array of words.
1008
1009 Based on all these entries and keys and values,
1010 the function creates two giant hashes:
1011 C<%decomplist>, which holds the decomposition rules for
1012 each keyword, and C<%reasmblist>, which holds the
1013 reassembly phrases for each decomposition rule.
1014 It also creates C<%keyranks>, which holds the ranks for
1015 each key.
1016
1017 Six other arrays are created: C<%reasm_for_memory, %pre, %post,
1018 %synon, @initial,> and C<@final>.
1019
1020 =cut
1021
1022 sub parse_script_data {
1023
1024 my ($self,$scriptfile) = @_;
1025 my @scriptlines;
1026
1027 if ($scriptfile) {
1028
1029 # If we have an external script file, open it
1030 # and read it in (the whole thing, all at once).
1031 open (SCRIPTFILE, "<$scriptfile")
1032 or die "Could not read from file $scriptfile : $!\n";
1033 @scriptlines = <SCRIPTFILE>; # read in script data
1034 $self->scriptfile($scriptfile);
1035 close (SCRIPTFILE);
1036
1037 } else {
1038
1039 # Otherwise, read in the data from the bottom
1040 # of this file. This data might be read several
1041 # times, so we save the offset pointer and
1042 # reset it when we're done.
1043 my $where= tell(DATA);
1044 @scriptlines = <DATA>; # read in script data
1045 seek(DATA, $where, 0);
1046 $self->scriptfile('');
1047 }
1048
1049 my ($entrytype, $entry, $key, $value) ;
1050 my $thiskey = "";
1051 my $thisdecomp = "";
1052
1053 ############################################################
1054 # Examine each line of script data.
1055 for (@scriptlines) {
1056
1057 # Skip comments and lines with only whitespace.
1058 next if (/^\s*#/ || /^\s*$/);
1059
1060 # Split entrytype and entry, using a colon as the delimiter.
1061 ($entrytype, $entry) = $_ =~ m/^\s*(\S*)\s*:\s*(.*)\s*$/;
1062
1063 # Case loop, based on the entrytype.
1064 for ($entrytype) {
1065
1066 /quit/ and do { push @{ $self->{quit} }, $entry; last; };
1067 /initial/ and do { push @{ $self->{initial} }, $entry; last; };
1068 /final/ and do { push @{ $self->{final} }, $entry; last; };
1069
1070 /decomp/ and do {
1071 die "$0: error parsing script: decomposition rule with no keyword.\n"
1072 if $thiskey eq "";
1073 $thisdecomp = join($;,$thiskey,$entry);
1074 push @{ $self->{decomplist}->{$thiskey} }, $entry ;
1075 last;
1076 };
1077
1078 /reasmb/ and do {
1079 die "$0: error parsing script: reassembly rule with no decomposition rule.\n"
1080 if $thisdecomp eq "";
1081 push @{ $self->{reasmblist}->{$thisdecomp} }, $entry ;
1082 last;
1083 };
1084
1085 /reasm_for_memory/ and do {
1086 die "$0: error parsing script: reassembly rule with no decomposition rule.\n"
1087 if $thisdecomp eq "";
1088 push @{ $self->{reasmblist_for_memory}->{$thisdecomp} }, $entry ;
1089 last;
1090 };
1091
1092 # The entrytypes below actually expect to see a key and value
1093 # pair in the entry, so we split them out. The first word,
1094 # separated by a space, is the key, and everything else is
1095 # an array of values.
1096
1097 ($key,$value) = $entry =~ m/^\s*(\S*)\s*(.*)/;
1098
1099 /pre/ and do { $self->{pre}->{$key} = $value; last; };
1100 /post/ and do { $self->{post}->{$key} = $value; last; };
1101
1102 # synon expects an array, so we split $value into an array, using " " as delimiter.
1103 /synon/ and do { $self->{synon}->{$key} = [ split /\ /, $value ]; last; };
1104
1105 /key/ and do {
1106 $thiskey = $key;
1107 $thisdecomp = "";
1108 $self->{keyranks}->{$thiskey} = $value ;
1109 last;
1110 };
1111
1112 } # End for ($entrytype) (case loop)
1113
1114 } # End for (@scriptlines)
1115
1116 } # End of method parse_script_data
1117
1118
1119 # Eliminate some pesky warnings.
1120 #
1121 sub DESTROY {}
1122
1123
1124 # ---{ E N D M E T H O D S }----------------------------------
1125 ####################################################################
1126
1127 1; # Return a true value.
1128
1129
1130 =head1 COPYRIGHT AND LICENSE
1131
1132 This software is copyright (c) 2003 by John Nolan E<lt>jpnolan@sonic.netE<gt>.
1133
1134 This is free software; you can redistribute it and/or modify it under
1135 the same terms as the Perl 5 programming language system itself.
1136
1137 =head1 AUTHOR
1138
1139 John Nolan jpnolan@sonic.net January 2003.
1140
1141 Implements the classic Eliza algorithm by Prof. Joseph Weizenbaum.
1142 Script format devised by Charles Hayden.
1143
1144 =cut
1145
1146
1147
1148 ####################################################################
1149 # ---{ B E G I N D E F A U L T S C R I P T D A T A }----------
1150 #
1151 # This script was prepared by Chris Hayden. Hayden's Eliza
1152 # program was written in Java, however, it attempted to match
1153 # the functionality of Weizenbaum's original program as closely
1154 # as possible.
1155 #
1156 # Hayden's script format was quite different from Weizenbaum's,
1157 # but it maintained the same content. I have adapted Hayden's
1158 # script format, since it was simple and convenient enough
1159 # for my purposes.
1160 #
1161 # I've made small modifications here and there.
1162 #
1163
1164 # We use the token __DATA__ rather than __END__,
1165 # so that all this data is visible within the current package.
1166
1167 __DATA__
1168 initial: How do you do. Please tell me your problem.
1169 initial: Hello, I am a computer program.
1170 initial: Please tell me what's been bothering you.
1171 initial: Is something troubling you?
1172 final: Goodbye. It was nice talking to you.
1173 final: Goodbye. I hope you found this session helpful.
1174 final: I think you should talk to a REAL analyst. Ciao!
1175 final: Life is tough. Hang in there!
1176 quit: bye
1177 quit: goodbye
1178 quit: done
1179 quit: exit
1180 quit: quit
1181 pre: dont don't
1182 pre: cant can't
1183 pre: wont won't
1184 pre: recollect remember
1185 pre: recall remember
1186 pre: dreamt dreamed
1187 pre: dreams dream
1188 pre: maybe perhaps
1189 pre: certainly yes
1190 pre: machine computer
1191 pre: machines computer
1192 pre: computers computer
1193 post: am are
1194 post: your my
1195 post: yours mine
1196 pre: were was
1197 post: me you
1198 pre: you're you are
1199 pre: i'm i am
1200 post: myself yourself
1201 post: yourself myself
1202 post: i you
1203 post: you me
1204 post: my your
1205 post: me you
1206 post: i'm you are
1207 pre: same alike
1208 pre: identical alike
1209 pre: equivalent alike
1210 synon: belief feel think believe wish
1211 synon: family mother mom father dad sister brother wife children child
1212 synon: desire want need
1213 synon: sad unhappy depressed sick
1214 synon: happy elated glad better
1215 synon: cannot can't
1216 synon: everyone everybody nobody noone
1217 synon: be am is are was
1218 key: xnone -1
1219 decomp: *
1220 reasmb: I'm not sure I understand you fully.
1221 reasmb: Please go on.
1222 reasmb: That is interesting. Please continue.
1223 reasmb: Tell me more about that.
1224 reasmb: Does talking about this bother you ?
1225 key: sorry 0
1226 decomp: *
1227 reasmb: Please don't apologise.
1228 reasmb: Apologies are not necessary.
1229 reasmb: I've told you that apologies are not required.
1230 reasmb: It did not bother me. Please continue.
1231 key: apologise 0
1232 decomp: *
1233 reasmb: goto sorry
1234 key: remember 5
1235 decomp: * i remember *
1236 reasmb: Do you often think of (2) ?
1237 reasmb: Does thinking of (2) bring anything else to mind ?
1238 reasmb: What else do you recollect ?
1239 reasmb: Why do you remember (2) just now ?
1240 reasmb: What in the present situation reminds you of (2) ?
1241 reasmb: What is the connection between me and (2) ?
1242 reasmb: What else does (2) remind you of ?
1243 decomp: * do you remember *
1244 reasmb: Did you think I would forget (2) ?
1245 reasmb: Why do you think I should recall (2) now ?
1246 reasmb: What about (2) ?
1247 reasmb: goto what
1248 reasmb: You mentioned (2) ?
1249 decomp: * you remember *
1250 reasmb: How could I forget (2) ?
1251 reasmb: What about (2) should I remember ?
1252 reasmb: goto you
1253 key: forget 5
1254 decomp: * i forget *
1255 reasmb: Can you think of why you might forget (2) ?
1256 reasmb: Why can't you remember (2) ?
1257 reasmb: How often do you think of (2) ?
1258 reasmb: Does it bother you to forget that ?
1259 reasmb: Could it be a mental block ?
1260 reasmb: Are you generally forgetful ?
1261 reasmb: Do you think you are suppressing (2) ?
1262 decomp: * did you forget *
1263 reasmb: Why do you ask ?
1264 reasmb: Are you sure you told me ?
1265 reasmb: Would it bother you if I forgot (2) ?
1266 reasmb: Why should I recall (2) just now ?
1267 reasmb: goto what
1268 reasmb: Tell me more about (2).
1269 key: if 3
1270 decomp: * if *
1271 reasmb: Do you think its likely that (2) ?
1272 reasmb: Do you wish that (2) ?
1273 reasmb: What do you know about (2) ?
1274 reasmb: Really, if (2) ?
1275 reasmb: What would you do if (2) ?
1276 reasmb: But what are the chances that (2) ?
1277 reasmb: What does this speculation lead to ?
1278 key: dreamed 4
1279 decomp: * i dreamed *
1280 reasmb: Really, (2) ?
1281 reasmb: Have you ever fantasized (2) while you were awake ?
1282 reasmb: Have you ever dreamed (2) before ?
1283 reasmb: goto dream
1284 key: dream 3
1285 decomp: *
1286 reasmb: What does that dream suggest to you ?
1287 reasmb: Do you dream often ?
1288 reasmb: What persons appear in your dreams ?
1289 reasmb: Do you believe that dreams have something to do with your problem ?
1290 key: perhaps 0
1291 decomp: *
1292 reasmb: You don't seem quite certain.
1293 reasmb: Why the uncertain tone ?
1294 reasmb: Can't you be more positive ?
1295 reasmb: You aren't sure ?
1296 reasmb: Don't you know ?
1297 reasmb: How likely, would you estimate ?
1298 key: name 15
1299 decomp: *
1300 reasmb: I am not interested in names.
1301 reasmb: I've told you before, I don't care about names -- please continue.
1302 key: deutsch 0
1303 decomp: *
1304 reasmb: goto xfremd
1305 reasmb: I told you before, I don't understand German.
1306 key: francais 0
1307 decomp: *
1308 reasmb: goto xfremd
1309 reasmb: I told you before, I don't understand French.
1310 key: italiano 0
1311 decomp: *
1312 reasmb: goto xfremd
1313 reasmb: I told you before, I don't understand Italian.
1314 key: espanol 0
1315 decomp: *
1316 reasmb: goto xfremd
1317 reasmb: I told you before, I don't understand Spanish.
1318 key: xfremd 0
1319 decomp: *
1320 reasmb: I speak only English.
1321 key: hello 0
1322 decomp: *
1323 reasmb: How do you do. Please state your problem.
1324 reasmb: Hi. What seems to be your problem ?
1325 key: computer 50
1326 decomp: *
1327 reasmb: Do computers worry you ?
1328 reasmb: Why do you mention computers ?
1329 reasmb: What do you think machines have to do with your problem ?
1330 reasmb: Don't you think computers can help people ?
1331 reasmb: What about machines worries you ?
1332 reasmb: What do you think about machines ?
1333 key: am 0
1334 decomp: * am i *
1335 reasmb: Do you believe you are (2) ?
1336 reasmb: Would you want to be (2) ?
1337 reasmb: Do you wish I would tell you you are (2) ?
1338 reasmb: What would it mean if you were (2) ?
1339 reasmb: goto what
1340 decomp: * i am *
1341 reasmb: goto i
1342 decomp: *
1343 reasmb: Why do you say 'am' ?
1344 reasmb: I don't understand that.
1345 key: are 0
1346 decomp: * are you *
1347 reasmb: Why are you interested in whether I am (2) or not ?
1348 reasmb: Would you prefer if I weren't (2) ?
1349 reasmb: Perhaps I am (2) in your fantasies.
1350 reasmb: Do you sometimes think I am (2) ?
1351 reasmb: goto what
1352 reasmb: Would it matter to you ?
1353 reasmb: What if I were (2) ?
1354 decomp: * you are *
1355 reasmb: goto you
1356 decomp: * are *
1357 reasmb: Did you think they might not be (2) ?
1358 reasmb: Would you like it if they were not (2) ?
1359 reasmb: What if they were not (2) ?
1360 reasmb: Are they always (2) ?
1361 reasmb: Possibly they are (2).
1362 reasmb: Are you positive they are (2) ?
1363 key: your 0
1364 decomp: * your *
1365 reasmb: Why are you concerned over my (2) ?
1366 reasmb: What about your own (2) ?
1367 reasmb: Are you worried about someone else's (2) ?
1368 reasmb: Really, my (2) ?
1369 reasmb: What makes you think of my (2) ?
1370 reasmb: Do you want my (2) ?
1371 key: was 2
1372 decomp: * was i *
1373 reasmb: What if you were (2) ?
1374 reasmb: Do you think you were (2) ?
1375 reasmb: Were you (2) ?
1376 reasmb: What would it mean if you were (2) ?
1377 reasmb: What does ' (2) ' suggest to you ?
1378 reasmb: goto what
1379 decomp: * i was *
1380 reasmb: Were you really ?
1381 reasmb: Why do you tell me you were (2) now ?
1382 reasmb: Perhaps I already know you were (2).
1383 decomp: * was you *
1384 reasmb: Would you like to believe I was (2) ?
1385 reasmb: What suggests that I was (2) ?
1386 reasmb: What do you think ?
1387 reasmb: Perhaps I was (2).
1388 reasmb: What if I had been (2) ?
1389 key: i 0
1390 decomp: * i @desire *
1391 reasmb: What would it mean to you if you got (3) ?
1392 reasmb: Why do you want (3) ?
1393 reasmb: Suppose you got (3) soon.
1394 reasmb: What if you never got (3) ?
1395 reasmb: What would getting (3) mean to you ?
1396 reasmb: What does wanting (3) have to do with this discussion ?
1397 decomp: * i am* @sad *
1398 reasmb: I am sorry to hear that you are (3).
1399 reasmb: Do you think coming here will help you not to be (3) ?
1400 reasmb: I'm sure it's not pleasant to be (3).
1401 reasmb: Can you explain what made you (3) ?
1402 decomp: * i am* @happy *
1403 reasmb: How have I helped you to be (3) ?
1404 reasmb: Has your treatment made you (3) ?
1405 reasmb: What makes you (3) just now ?
1406 reasmb: Can you explain why you are suddenly (3) ?
1407 decomp: * i was *
1408 reasmb: goto was
1409 decomp: * i @belief i *
1410 reasmb: Do you really think so ?
1411 reasmb: But you are not sure you (3).
1412 reasmb: Do you really doubt you (3) ?
1413 decomp: * i* @belief *you *
1414 reasmb: goto you
1415 decomp: * i am *
1416 reasmb: Is it because you are (2) that you came to me ?
1417 reasmb: How long have you been (2) ?
1418 reasmb: Do you believe it is normal to be (2) ?
1419 reasmb: Do you enjoy being (2) ?
1420 reasmb: Do you know anyone else who is (2) ?
1421 decomp: * i @cannot *
1422 reasmb: How do you know that you can't (3) ?
1423 reasmb: Have you tried ?
1424 reasmb: Perhaps you could (3) now.
1425 reasmb: Do you really want to be able to (3) ?
1426 reasmb: What if you could (3) ?
1427 decomp: * i don't *
1428 reasmb: Don't you really (2) ?
1429 reasmb: Why don't you (2) ?
1430 reasmb: Do you wish to be able to (2) ?
1431 reasmb: Does that trouble you ?
1432 decomp: * i feel *
1433 reasmb: Tell me more about such feelings.
1434 reasmb: Do you often feel (2) ?
1435 reasmb: Do you enjoy feeling (2) ?
1436 reasmb: Of what does feeling (2) remind you ?
1437 decomp: * i * you *
1438 reasmb: Perhaps in your fantasies we (2) each other.
1439 reasmb: Do you wish to (2) me ?
1440 reasmb: You seem to need to (2) me.
1441 reasmb: Do you (2) anyone else ?
1442 decomp: *
1443 reasmb: You say (1) ?
1444 reasmb: Why do you say (1) ?
1445 reasmb: Can you elaborate on that ?
1446 reasmb: Do you say (1) for some special reason ?
1447 reasmb: That's quite interesting.
1448 key: you 0
1449 decomp: * you remind me of *
1450 reasmb: goto alike
1451 decomp: * you are *
1452 reasmb: What makes you think I am (2) ?
1453 reasmb: Does it please you to believe I am (2) ?
1454 reasmb: Do you sometimes wish you were (2) ?
1455 reasmb: Perhaps you would like to be (2).
1456 decomp: * you* me *
1457 reasmb: Why do you think I (2) you ?
1458 reasmb: You like to think I (2) you -- don't you ?
1459 reasmb: What makes you think I (2) you ?
1460 reasmb: Really, I (2) you ?
1461 reasmb: Do you wish to believe I (2) you ?
1462 reasmb: Suppose I did (2) you -- what would that mean ?
1463 reasmb: Does someone else believe I (2) you ?
1464 decomp: * you *
1465 reasmb: We were discussing you -- not me.
1466 reasmb: Oh, I (2) ?
1467 reasmb: You're not really talking about me -- are you ?
1468 reasmb: What are your feelings now ?
1469 key: yes 0
1470 decomp: *
1471 reasmb: Please go on.
1472 reasmb: Please tell me some more about this.
1473 reasmb: Why don't you tell me a little more about this.
1474 reasmb: I see.
1475 reasmb: I understand.
1476 key: no 0
1477 decomp: * no one *
1478 reasmb: Are you sure, no one (2) ?
1479 reasmb: Surely someone (2) .
1480 reasmb: Can you think of anyone at all ?
1481 reasmb: Are you thinking of a very special person ?
1482 reasmb: Who, may I ask ?
1483 reasmb: You have a particular person in mind, don't you ?
1484 reasmb: Who do you think you are talking about ?
1485 decomp: *
1486 reasmb: Are you saying no just to be negative?
1487 reasmb: Does this make you feel unhappy?
1488 reasmb: Why not ?
1489 reasmb: Why 'no' ?
1490 key: my 2
1491 decomp: * my* @family *
1492 reasmb: Tell me more about your family.
1493 reasmb: Who else in your family (4) ?
1494 reasmb: Your (3) ?
1495 reasmb: What else comes to mind when you think of your (3) ?
1496 decomp: * my *
1497 reasmb: Your (2) ?
1498 reasmb: Why do you say your (2) ?
1499 reasmb: Does that suggest anything else which belongs to you ?
1500 reasmb: Is it important to you that your (2) ?
1501 reasm_for_memory: Let's discuss further why your (2).
1502 reasm_for_memory: Earlier you said your (2).
1503 reasm_for_memory: But your (2).
1504 reasm_for_memory: Does that have anything to do with the fact that your (2) ?
1505 key: can 0
1506 decomp: * can you *
1507 reasmb: You believe I can (2) don't you ?
1508 reasmb: goto what
1509 reasmb: You want me to be able to (2).
1510 reasmb: Perhaps you would like to be able to (2) yourself.
1511 decomp: * can i *
1512 reasmb: Whether or not you can (2) depends on you more than on me.
1513 reasmb: Do you want to be able to (2) ?
1514 reasmb: Perhaps you don't want to (2).
1515 reasmb: goto what
1516 key: what 0
1517 decomp: *
1518 reasmb: Why do you ask ?
1519 reasmb: Does that question interest you ?
1520 reasmb: What is it you really want to know ?
1521 reasmb: Are such questions much on your mind ?
1522 reasmb: What answer would please you most ?
1523 reasmb: What do you think ?
1524 reasmb: What comes to mind when you ask that ?
1525 reasmb: Have you asked such questions before ?
1526 reasmb: Have you asked anyone else ?
1527 key: who 0
1528 decomp: who *
1529 reasmb: goto what
1530 key: when 0
1531 decomp: when *
1532 reasmb: goto what
1533 key: where 0
1534 decomp: where *
1535 reasmb: goto what
1536 key: how 0
1537 decomp: how *
1538 reasmb: goto what
1539 key: because 0
1540 decomp: *
1541 reasmb: Is that the real reason ?
1542 reasmb: Don't any other reasons come to mind ?
1543 reasmb: Does that reason seem to explain anything else ?
1544 reasmb: What other reasons might there be ?
1545 key: why 0
1546 decomp: * why don't you *
1547 reasmb: Do you believe I don't (2) ?
1548 reasmb: Perhaps I will (2) in good time.
1549 reasmb: Should you (2) yourself ?
1550 reasmb: You want me to (2) ?
1551 reasmb: goto what
1552 decomp: * why can't i *
1553 reasmb: Do you think you should be able to (2) ?
1554 reasmb: Do you want to be able to (2) ?
1555 reasmb: Do you believe this will help you to (2) ?
1556 reasmb: Have you any idea why you can't (2) ?
1557 reasmb: goto what
1558 decomp: *
1559 reasmb: goto what
1560 key: everyone 2
1561 decomp: * @everyone *
1562 reasmb: Really, (2) ?
1563 reasmb: Surely not (2).
1564 reasmb: Can you think of anyone in particular ?
1565 reasmb: Who, for example?
1566 reasmb: Are you thinking of a very special person ?
1567 reasmb: Who, may I ask ?
1568 reasmb: Someone special perhaps ?
1569 reasmb: You have a particular person in mind, don't you ?
1570 reasmb: Who do you think you're talking about ?
1571 key: everybody 2
1572 decomp: *
1573 reasmb: goto everyone
1574 key: nobody 2
1575 decomp: *
1576 reasmb: goto everyone
1577 key: noone 2
1578 decomp: *
1579 reasmb: goto everyone
1580 key: always 1
1581 decomp: *
1582 reasmb: Can you think of a specific example ?
1583 reasmb: When ?
1584 reasmb: What incident are you thinking of ?
1585 reasmb: Really, always ?
1586 key: alike 10
1587 decomp: *
1588 reasmb: In what way ?
1589 reasmb: What resemblence do you see ?
1590 reasmb: What does that similarity suggest to you ?
1591 reasmb: What do you suppose that resemblence means ?
1592 reasmb: What is the connection, do you suppose ?
1593 reasmb: Could there really be some connection ?
1594 reasmb: How ?
1595 key: like 10
1596 decomp: * @be *like *
1597 reasmb: goto alike
1598 key: different 0
1599 decomp: *
1600 reasmb: How is it different ?
1601 reasmb: What differences do you see ?
1602 reasmb: What does that difference suggest to you ?
1603 reasmb: What other distinctions do you see ?
1604 reasmb: What do you suppose that disparity means ?
1605 reasmb: Could there be some connection, do you suppose ?
1606 reasmb: How ?
1607 key: fuck 10
1608 decomp: *
1609 reasmb: goto xswear
1610 key: fucker 10
1611 decomp: *
1612 reasmb: goto xswear
1613 key: shit 10
1614 decomp: *
1615 reasmb: goto xswear
1616 key: damn 10
1617 decomp: *
1618 reasmb: goto xswear
1619 key: shut 10
1620 decomp: * shut up *
1621 reasmb: goto xswear
1622 key: xswear 10
1623 decomp: *
1624 reasmb: Does it make you feel strong to use that kind of language ?
1625 reasmb: Are you venting your feelings now ?
1626 reasmb: Are you angry ?
1627 reasmb: Does this topic make you feel angry ?
1628 reasmb: Is something making you feel angry ?
1629 reasmb: Does using that kind of language make you feel better ?
0 #!perl
1
2 use strict;
3 use warnings;
4
5 use Test::More 0.88 tests => 1;
6
7 require_ok('Chatbot::Eliza');
0 #!perl
1
2 use strict;
3 use warnings;
4 use Chatbot::Eliza;
5 use Test::More 0.88;
6
7 my @TESTS =
8 (
9 [ 'I feel happy' => 'Do you often feel happy?' ],
10 [ 'I like blueberries' => 'I like blueberries too!' ],
11 [ 'xyzzy' => 'Huh?' ],
12 );
13 my ($input, $output, $expected);
14
15 plan tests => int(@TESTS);
16
17 my $bot = Chatbot::Eliza->new('TestBot', 't/test-script.txt')
18 || BAIL_OUT;
19
20 foreach my $test (@TESTS) {
21 ($input, $expected) = @$test;
22 $output = $bot->transform($input);
23 is($output, $expected, "Do we get expected output for '$input'");
24 }
25
0 key: xnone -1
1 decomp: *
2 reasmb: Huh?
3 key: feel 1
4 decomp: * i feel *
5 reasmb: Do you often feel (2)?
6 key: like 1
7 decomp: i like *
8 reasmb: I like (1) too!