Name
Eliza::Chatbot::Brain
VERSION
Version 0.02
SUBROUTINES/METHODS
transform
$reply = $chatterbot->transform( $string, $use_memory );
transform applies transformation rules to the user input string. It invokes preprocess(), does transformations, then invokes postprocess. It returns the transformed output string, called $reasmb
The algorithm embedded in the transfrom method has three main parts:
Searn the input string for a keyword.
If we find a keyword, use the list of demoposition rules for that keyword. and pattern-match the input string against each rule.
If the input string matches any of the decomposition rules, then randomly select one of the reassembly rules for that decomposition rule, and use it to construct the reply.
transform takes two parameters. The first is the string we want to transform. The second is a flag which indicates where this string came from. If the flag is set, then the string has been pulled from memory, and we should use reassemble rules appropriate for that. If the flag is not set then the string is the most recent user input, and we can use the ordinary reassembly rules.
The memory flag is only set when the transform function is called recursively. The mechanism for setting this parameter is embedded in he transform method itself. If the flag is set inappropriately, it is ignored.
preprocess
$string = preprocess($string);
preprocess() applies simple substitution rules to the input string. Mostly this is to catch varieties in spelling, misspellings, contractions and the like.
preprocess() is called from within the transform() method. It is applied to user-input text, BEFORE any processing, and before a reassebly statement has been selected.
It uses the array %pre
, which is created during the parse of the script.
postprocess
$string = postprocess($string);
postprocess() applies simple substitution rules to the reassembly rule. This is where all the "I"'s and "you"'s are exchanged. postprocess() is called from within the transform() function.
It uses the attribute %post
, created during the parse of the script.
_test_quit
$self->_test_quit($user_input) ) { }
_test_quit detects words like "bye" and "quit" and returns true if it finds one of them as the first word in the sentence.
Thes words are listed in the script, under the keyword "quit".
_debug_memory
$self->_debug_memory
_debug_memory is a special function hwihc returns the contents of Eliza's memory stack.
AUTHOR
LNATION thisusedtobeanemail@gmail.com
ACKNOWLEDGEMENTS
I started here Chatbot::Eliza and then got a little carried away.
LICENSE AND COPYRIGHT
Copyright 2017 Robert Acock.
This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:
http://www.perlfoundation.org/artistic_license_2_0
Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.
If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.
This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.
This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
AUTHOR
LNATION thisusedtobeanemail@gmail.com
LICENSE AND COPYRIGHT
Copyright 2017 Robert Acock.
This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:
http://www.perlfoundation.org/artistic_license_2_0
Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.
If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.
This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.
This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.