The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

RiveScript-Perl

Build Status

NAME

RiveScript - Rendering Intelligence Very Easily

SYNOPSIS

```perl use RiveScript;

Create a new RiveScript interpreter.

my $rs = new RiveScript;

Load a directory of replies.

$rs->loadDirectory ("./replies");

Load another file.

$rs->loadFile ("./more_replies.rive");

Stream in some RiveScript code.

$rs->stream (q~ + hello bot - Hello, human. ~);

Sort all the loaded replies.

$rs->sortReplies;

Chat with the bot.

while (1) { print "You> "; chomp (my $msg = ); my $reply = $rs->reply ('localuser',$msg); print "Bot> $reply\n"; } ```

DESCRIPTION

RiveScript is a simple trigger/response language primarily used for the creation of chatting robots. It's designed to have an easy-to-learn syntax but provide a lot of power and flexibility. For more information, visit http://www.rivescript.com/

METHODS

GENERAL

LOADING AND PARSING

CONFIGURATION

INTERACTION

RIVESCRIPT

This interpreter tries its best to follow RiveScript standards. Currently it supports RiveScript 2.0 documents. A current copy of the RiveScript working draft is included with this package: see RiveScript::WD.

UTF-8 SUPPORT

RiveScript supports Unicode but it is not enabled by default. Enable it by passing a true value for the utf8 option in the constructor, or by using the --utf8 argument to the rivescript application.

In UTF-8 mode, most characters in a user's message are left intact, except for certain metacharacters like backslashes and common punctuation characters like /[.,!?;:]/.

If you want to override the punctuation regexp, you can provide a new one by assigning the `unicode_punctuation` attribute of the bot object after initialization. Example:

perl my $bot = new RiveScript(utf8 => 1); $bot->{unicode_punctuation} = qr/[.,!?;:]/;

CONSTANTS

This module can export some constants.

use RiveScript qw(:standard);

These constants include:

SEE ALSO

RiveScript::WD - A current snapshot of the Working Draft that defines the standards of RiveScript.

http://www.rivescript.com/ - The official homepage of RiveScript.

CHANGES

2.0.3  Aug 26 2016
- Fix inline comment regexp that was making URLs impossible to represent
  in replies.

2.0.0  Dec 28 2015
- Switch from old-style floating point version number notation to dotted
  decimal notation. This bumps the version number to `2.0.0` because the next
  dotted-decimal version greater than `1.42` (`v1.420.0`) is `v1.421.0` and
  I don't like having that many digits in the version number. This release is
  simply a version update; no breaking API changes were introduced.

1.42  Nov 20 2015
- Add configurable `unicode_punctuation` attribute to strip out punctuation
  when running in UTF-8 mode.

1.40  Oct 10 2015
- Fix the regexp used when matching optionals so that the triggers don't match
  on inputs where they shouldn't. (RiveScript-JS issue #46)

1.38  Jul 21 2015
- New algorithm for handling variable tags (<get>, <set>, <add>, <sub>,
  <mult>, <div>, <bot> and <env>) that allows for iterative nesting of these
  tags (for example, <set copy=<get orig>> will work now).
- Fix trigger sorting so that triggers with matching word counts are sorted
  by length descending.
- Add support for `! local concat` option to override concatenation mode
  (file scoped)
- Bugfix where Perl object macros set via `setSubroutine()` failed to load
  because they were missing a programming language internally.

1.36  Nov 26 2014
- Relicense under the MIT License.
- Strip punctuation from the bot's responses in UTF-8 mode to
  support compatibility with %Previous.
- Bugfix in deparse(): If you had two matching triggers, one with a %Previous
  and one without, you'd lose the data for one of them in the output.

1.34  Feb 26 2014
- Update README.md to include module documentation for github.
- Fixes to META.yml

1.32  Feb 24 2014
- Maintenance release to fix some errors per the CPANTS.
- Add license to Makefile.PL
- Make Makefile.PL not executable
- Make version numbers consistent

1.30  Nov 25 2013
- Added "TCP Mode" to the `rivescript` command so that it can listen on a
  socket instead of using standard input and output.
- Added a "--data" option to the `rivescript` command for providing JSON
  input as a command line argument instead of standard input.
- Added experimental UTF-8 support.
- Bugfix: don't use hacky ROT13-encoded placeholders for message
  substitutions... use a null character method instead. ;)
- Make .rive the default preferred file extension for RiveScript documents
  instead of .rs (which conflicts with the Rust programming language).
  Backwards compatibility remains to load .rs files, though.

See the Changes file for older change history.

AUTHOR

Noah Petherbridge, http://www.kirsle.net

KEYWORDS

bot, chatbot, chatterbot, chatter bot, reply, replies, script, aiml, alpha

COPYRIGHT AND LICENSE

The MIT License (MIT)

Copyright (c) 2015 Noah Petherbridge

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.