Giter Club home page Giter Club logo

rivescript-perl's People

Contributors

kirsle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rivescript-perl's Issues

Need a way to match a single word that has both letters and numbers in it.

Using it for an ingame AI and some usernames have numbers in them example: "Joe32"

I want to catch the first word as it is always the user name. Using an _ will catch it only if the word has no numbers in it and using a # will only catch a number. Using a * will catch more than a single word and mess up the matches.

Begin block and weight tag

Hi. When I'm using weight tag in begin block it seems like it's ignored.
With this code bot is abusing emotes:
* <bot mood> == happy => {random}
^ {ok}{weight=20}|
^ {ok} :){weight=2}|
^ {ok} ;){weight=2}|
^ {ok} :P|
^ {ok} ;P{/random}
With this not:
* <bot mood> == happy => {random}
^ {ok}|{ok}|{ok}|{ok}|{ok}|{ok}|{ok}|{ok}|{ok}|{ok}|{ok}|{ok}|{ok}|{ok}|
^ {ok} :)|{ok} :)|
^ {ok} ;)|{ok} ;)|
^ {ok} :P|
^ {ok} ;P{/random}

Nesting random tag inside random tag

Hi. If I try to insert random tag inside random tag:
+ <bot name>
* <get it> == undefined => {random}
^ {random}Yes?|Yea?{/random}|
^ Yea?{/random}
- What's up?
I'm getting this output:
Yea?|Yea?{/random}
I'm using default response in begin block:
* <bot mood> == happy => {ok}
If I use that code in begin block:
* <bot mood> == happy => {random}
^ {ok}|{ok}|{ok}|{ok}|{ok}|{ok}|{ok}|{ok}|{ok}|{ok}|{ok}|{ok}|{ok}|{ok}|
^ {ok} :)|{ok} :)|
^ {ok} ;)|{ok} ;)|
^ {ok} :P|
^ {ok} ;P{/random}
The response is even more strange:
Yea?|Yea?|Yea?{/random}|Yea?|Yea?{/random}|Yea?|Yea?{/random}|Yea?|Yea?{/random}|Yea?|Yea?{/random}|Yea?|Yea?{/random}|Yea?|Yea?{/random}|Yea?|Yea?{/random}|Yea?|Yea?{/random}|Yea?|Yea?{/random}|Yea?|Yea?{/random}|Yea?|Yea?{/random}|Yea?|Yea?{/random}|Yea?|Yea?{/random} :)|Yea?|Yea?{/random} :)|Yea?|Yea?{/random} ;)|Yea?|Yea?{/random} ;)|Yea?|Yea?{/random} :P|Yea?|Yea?{/random} ;P{/random}

Feature: Conditionals with arrays

Hi Noah,

i have a feature request: I'd like to see if a star.. value is contained in an array when comparing in a condition (*). So a Code like this:

! array room_livingroom = living room|living
! array room_bedroom = bedroom|master bed room|bed room

+ *
* <star1> == @room_livingroom => This is the living room
* <star1> == @room_bedroom => This is the bedroom

Is that already possible and this is just the wrong way or is this something new? Thanks in advance for your reply!

Best Regards,
Uli

UTF-8 Issues for foreign characters

Hello,

i am currently writing a german chatbot which should be reacting to characters like "üöä" properly. It never really did except for the code i actively stream in and then only for the session, therefore i tried to narrow that down. Currently i don't seem to get that working properly, below is the minimal code that i needed to reproduce the example.

My example code test.pl

  use RiveScript;

  my %rivescriptconfig = ('utf8'       => 1);

  # Create a new RiveScript interpreter.
  my $rs = new RiveScript(%rivescriptconfig);

  # Load another file.
  $rs->loadFile ("./test.rive");

  # Stream in some RiveScript code.
  $rs->stream (q~
    + küchentemperatur
    - In der Küche ist es warm.
  ~);

  # Sort all the loaded replies.
  $rs->sortReplies;


  use Data::Dumper;
  print Dumper($rs->deparse());

  $rs->write ('./test-write.rive');

  # Chat with the bot.
  while (1) {
    print "You> ";
    chomp (my $msg = <STDIN>);
    my $reply = $rs->reply ('localuser',$msg);
    print "Bot> $reply\n";
  }

And the corresponding rivescript-file test.rive:

+ wie warm ist es in der küche
- Die temperatur in der Küche beträgt 27 Grad

When starting this script, the Dumper part throws:

$VAR1 = {
          'include' => {},
          'begin' => {
                       'sub' => {},
                       'that' => {},
                       'triggers' => {},
                       'var' => {},
                       'array' => {},
                       'global' => {},
                       'person' => {}
                     },
          'that' => {},
          'topic' => {
                       'random' => {
                                     "wie warm ist es in der k\x{fc}che" => {
                                                                        'reply' => [
                                                                                     "Die temperatur in der K\x{fc}che betr\x{e4}gt 27 Grad"
                                                                                   ]
                                                                      },
                                     'küchentemperatur' => {
                                                              'reply' => [
                                                                           'In der Küche ist es warm.'
                                                                         ]
                                                            }
                                   }
                     },
          'inherit' => {}
        };

Which already shows that "Küche" got now K\x{fc}che when being loaded from the file, but küchentemperatur, which i streamed in, stayed the same. Now i comes to the command prompt:

You> Küchentemperatur
Bot> In der Küche ist es warm.
You> Wie warm ist es in der Küche
Bot> ERR: No Reply Matched

This also confirms that the representation of the character is somehow wrong. Now lets look at the file test-write.rive that was written after the loading and streaming:

// Written by RiveScript::deparse()
! version = 2.0

+ küchentemperatur
- In der Küche ist es warm.

+ wie warm ist es in der k▒che
- Die temperatur in der K▒che betr▒gt 27 Grad

Alright definitely some bogus characters.

Well now lets load that file again (I disabled the streaming line of the above test.pl to not overwrite the file contents).

utf8 "\xFC" does not map to Unicode at /usr/local/share/perl/5.20.2/RiveScript.pm line 314, <$fh> line 7.
utf8 "\xFC" does not map to Unicode at /usr/local/share/perl/5.20.2/RiveScript.pm line 314, <$fh> line 8.
Malformed UTF-8 character (fatal) at /usr/local/share/perl/5.20.2/RiveScript.pm line 380.

If it helps to debug the issue:

# perl -v

This is perl 5, version 20, subversion 2 (v5.20.2) built for arm-linux-gnueabihf-thread-multi-64int
(with 42 registered patches, see perl -V for more detail)

I think it has something to do with: http://perldoc.perl.org/perlunicode.html#The-%22Unicode-Bug%22 but i am not sure what i can do to resolve it. Disabling utf8 in rivescript is not the solution, i think:

Syntax error in ./test.rive line 1: Triggers may only contain lowercase letters, numbers, and these symbols: ( | ) [ ] * _ # @ { } < > = (near: + wie warm ist es in der k▒che) at /usr/local/share/perl/5.20.2/RiveScript.pm line 488.

Thanks in advance for your help!

Array Names with underscores are not properly matched

Hi Noah,

when using an underscore in the array name, the array seems to be working improperly. Example rivescript:

! array wetter_frage = wie warm wird es|temperatur|wie kalt wird es
! array wetter_tage = heute|morgen|übermorgen

+ (@wetter_frage) [@wetter_tage]
- Die Temperaturen der nächsten Tage werden gemütlich

Result:

[16:56:09] RiveScript: Trying to match "wie warm wird es morgen" against (@wetter_frage) [@wetter_tage] ((([A-Za-z]+)frage)(?:(?:\s|\b)+(?:[A-Za-z]+)tage(?:\s|\b)+|(?:\s|\b)+))

When looking at the end of the line, the result is visible. After removing the underscores it works:

[16:58:01] RiveScript: Trying to match "wie warm wird es morgen" against (@wetterfrage) [@wettertage] (((?:wie warm wird es|temperatur|wie kalt wird es))(?:(?:\s|\b)+(?:heute|morgen|übermorgen)(?:\s|\b)+|(?:\s|\b)+))

Probably an easy fix for you?

Thanks in advance & Best Regards,
Uli

Feature: Arrays in arrays

Hi Noah,

i have a feature request: I'm looking for a possibility to pack arrays into arrays So a Code like this:

! array room_livingroom = living room|living
! array room_bedroom = bedroom|master bed room|bed room
! array rooms = @room_livingroom|@room_bedroom

Is that already possible and this is just the wrong way or is this something new? This would be my usecase:

! array location = in|on|at
! array question = how warm is it|temperatur|how cold is it|how many degrees

+ [@question] [@location] (@rooms)
* <star1> == @room_livingroom => The temperature in the living room currently is <call>readingsval LR_Wandthermostat temperature Error</call> °C
* <star1> == @room_bedroom => The temperature in the bedroom currently is <call>readingsval BR_Wandthermostat temperature Error</call> °C

Of course the solution of #6 would help for this (shown in this example), but even if not, this might help anyway. So the arrays would not be needed as nested but just for reasons of deduplication.

Thanks in advance for your reply!

Best Regards,
Uli

Edit 1: Just to clarify: Yes this can be done partly with the substitution if that is about the same room - this was just an example.
Edit 2: Fixed a Typo

Bug in demo chatbot

I found a small bug in the demo. In clients.rs, I think you want to change the line:

- <set location=<formal>>I've spoken to people from <get location> before.

to

- <set location={formal}<star2>{/formal}>I've spoken to people from <get location> before.

To prevent this:

You> I am from England
Bot> I've spoken to people from Am From before.

I think you need to do this in the Aires bot as well.

Show example for setSubroutine

Since a few days i am working with rivescript to integration this in an home automation project (chatting with your home ;) ). But somehow i seem to be unable to insert procedures using setSubroutine - could you show an example for this?

Thanks in advance!

Best Regards,
Uli

Condition validation is not 100% correct

Hi!,

While working on rivescript-php i was porting your checkSyntax function.

if ($line !~ /^.+?\s*(==|eq|!=|ne|<>|<|<=|>|>=)\s*.+?=>.+?$/) {
    return "Invalid format for !Condition: should be like `* value symbol value => response`";
}

This does not validate the usage of the == | != | ne | <> | < | <= | > | >= | characters.

The following script gets passed validation while the syntax of whats supposed to be eq male now says bleep male.

+ set gender
- <set gender=male>thank you

+ what is my gender
* <get gender> bleep male => You told me you were a boy.
* <get gender> eq female => You told me you were a girl.
- You never told me what you were.

I have tested this in the live testing environment as well and i didn't get any errors.

Strange behaviour when substituting "n" with "and"

Using this script:

$rs = RiveScript->new(debug => 0);
$rs->loadDirectory('./replies');
$rs->sortReplies;
say $rs->reply('localuser', "your a bot");

and these replies:

! sub n         = and
! sub your a    = you are a

+ you are a bot
- no i am not

produces:

ERR: No Reply Matched

however, removing the line "! sub n = and" outputs the correct response:

no i am not

I tried running with debug => 1 and it outputs this:

RiveScript: Get reply to [localuser] your a bot
RiveScript: Checking topic random for any %previous's.
RiveScript: Trying to match "you are ebg13fhoandbus31tor bot" against you are a bot (you are a bot)
RiveScript: Processing responses to this trigger.
RiveScript: Reply: ERR: No Reply Matched

which is quite strange

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.