~ubuntu-branches/ubuntu/vivid/librivescript-perl/vivid

« back to all changes in this revision

Viewing changes to lib/RiveScript.pm

  • Committer: Package Import Robot
  • Author(s): gregor herrmann
  • Date: 2012-08-25 21:21:27 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20120825212127-phm6b84x4grhbnfg
Tags: 1.28-1
* New upstream release.
* Drop spelling-errors.patch, merged upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
use strict;
4
4
use warnings;
5
5
 
6
 
our $VERSION = '1.26'; # Version of the Perl RiveScript interpreter.
 
6
our $VERSION = '1.28'; # Version of the Perl RiveScript interpreter.
7
7
our $SUPPORT = '2.0';  # Which RS standard we support.
8
8
our $basedir = (__FILE__ =~ /^(.+?)\.pm$/i ? $1 : '.');
9
9
 
 
10
# Constants.
 
11
use constant RS_ERR_MATCH => "ERR: No Reply Matched";
 
12
use constant RS_ERR_REPLY => "ERR: No Reply Found";
 
13
 
 
14
# Exports
 
15
require Exporter;
 
16
our @ISA         = qw(Exporter);
 
17
our @EXPORT_OK   = qw(RS_ERR_MATCH RS_ERR_REPLY);
 
18
our %EXPORT_TAGS = (
 
19
        standard => \@EXPORT_OK,
 
20
);
 
21
 
10
22
=head1 NAME
11
23
 
12
24
RiveScript - Rendering Intelligence Very Easily
2663
2675
 
2664
2676
        # Still no reply?
2665
2677
        if ($foundMatch == 0) {
2666
 
                $reply = "ERR: No Reply Matched";
 
2678
                $reply = RS_ERR_MATCH;
2667
2679
        }
2668
 
        elsif (length $reply == 0) {
2669
 
                $reply = "ERR: No Reply Found";
 
2680
        elsif (!defined $reply || length $reply == 0) {
 
2681
                $reply = RS_ERR_REPLY;
2670
2682
        }
2671
2683
 
2672
2684
        $self->debug ("Reply: $reply");
3170
3182
supports RiveScript 2.0 documents. A current copy of the RiveScript working
3171
3183
draft is included with this package: see L<RiveScript::WD>.
3172
3184
 
 
3185
=head1 CONSTANTS
 
3186
 
 
3187
This module can export some constants.
 
3188
 
 
3189
  use RiveScript qw(:standard);
 
3190
 
 
3191
These constants include:
 
3192
 
 
3193
=over 4
 
3194
 
 
3195
=item RS_ERR_MATCH
 
3196
 
 
3197
This is the reply text given when no trigger has matched the message. It equals
 
3198
"C<ERR: No Reply Matched>".
 
3199
 
 
3200
  if ($reply eq RS_ERR_MATCH) {
 
3201
    $reply = "I couldn't find a good reply for you!";
 
3202
  }
 
3203
 
 
3204
=item RS_ERR_REPLY
 
3205
 
 
3206
This is the reply text given when a trigger I<was> matched, but no reply was
 
3207
given from it (for example, the trigger only had conditionals and all of them
 
3208
were false, with no default replies to fall back on). It equals
 
3209
"C<ERR: No Reply Found>".
 
3210
 
 
3211
  if ($reply eq RS_ERR_REPLY) {
 
3212
    $reply = "I don't know what to say about that!";
 
3213
  }
 
3214
 
 
3215
=back
 
3216
 
3173
3217
=head1 SEE ALSO
3174
3218
 
3175
3219
L<RiveScript::WD> - A current snapshot of the Working Draft that
3179
3223
 
3180
3224
=head1 CHANGES
3181
3225
 
 
3226
  1.28  Aug 14 2012
 
3227
  - FIXED: Typos in RiveScript::WD (Bug #77618)
 
3228
  - Added constants RS_ERR_MATCH and RS_ERR_REPLY.
 
3229
 
3182
3230
  1.26  May 29 2012
3183
3231
  - Added EXE_FILES to Makefile.PL so the rivescript utility installs
3184
3232
    correctly.