Name
Eliza::Chatbot::ScriptParser
Version
Version 0.02
Options
- script_file
- quit
- initial
- final
- decomp
- reasmb
- reasmb_for_memory
- pre
- post
- synon
- key
- unique_words
SUBROUTINES/METHODS
parse_script_data()
$self->parse_script_data;
$self->parse_script_data( $script_file );
parse_script_data() is invoked from the _initialize() method, which is called from the new() function. However, you can also call this method at any time against an already-instantiated Eliza instance. In that case, the new script data is added to the old script data. The old script data is not deleted.
You can pass a parameter to this function, which is the name of the script file, and it will read in and parse that file. If you do not pass any parameter to this method, then it will read the data embedded at the end of the module as its default script data.
If you pass the name of a script file to parse_script_data(), and that file is not available for reading, then the module dies.
Format of the script file
This module includes a default script file within itself, so it is not necessary to explicitly specify a script file when instantiating an Eliza object. Each line in the script file can specify a key, a decomposition rule, or a reassembly rule.
key: remember 5
decomp: * i remember *
reasmb: Do you often think of (2) ?
reasmb: Does thinking of (2) bring anything else to mind ?
decomp: * do you remember *
reasmb: Did you think I would forget (2) ?
reasmb: What about (2) ?
reasmb: goto what
pre: equivalent alike
synon: belief feel think believe wish
The number after the key specifies the rank. If a user's input contains the keyword, then the transform() function will try to match one of the decomposition rules for that keyword. If one matches, then it will select one of the reassembly rules at random. The number (2) here means "use whatever set of words matched the second asterisk in the decomposition rule." If you specify a list of synonyms for a word, the you should use a "@" when you use that word in a decomposition rule:
decomp: * i @belief i *
reasmb: Do you really think so ?
reasmb: But you are not sure you (3).
Otherwise, the script will never check to see if there are any synonyms for that keyword. Reassembly rules should be marked with reasm_for_memory rather than reasmb when it is appropriate for use when a user's comment has been extracted from memory.
key: my 2
decomp: * my *
reasm_for_memory: Let's discuss further why your (2).
reasm_for_memory: Earlier you said your (2).
reasm_for_memory: But your (2).
reasm_for_memory: Does that have anything to do with the fact that your (2) ?
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.