aichaos / rivescript-java

A RiveScript interpreter for Java. RiveScript is a scripting language for chatterbots.
http://www.rivescript.com
MIT License
64 stars 38 forks source link

lowercase not work for variable #48

Open UshakovVasilii opened 7 years ago

UshakovVasilii commented 7 years ago
    RiveScript rs = new RiveScript();
    rs.stream(new String[] { //
        "! version = 2.0", //
        "+ a", //
        "- {lowercase}A{/lowercase}", //
        "+ b", //
        "- {lowercase}<get v>{/lowercase}"});
    rs.sortReplies();
    rs.setUservar("test", "v", "B");
    System.out.println(rs.reply("test", "a"));
    System.out.println(rs.reply("test", "b"));

output is:

a
B

It reproduced on 0.8. and 0.9. versions

marceloverdijk commented 7 years ago

This is indeed an issue with current implementations of RiveScript (Java, JS, Go, ..). The tag ordering, or better the ordering of processing the tags, has been picked carefully to support the common use cases. Processing the lowercase, formal etc formatting tags is done early, also to support e.g. <set name=<formal>>.

It would be better that RiveScript would parse/tokenize the whole message string so we are not dependent on the ordering, but this might be a quite big job to do.

In the short term I don't see this implemented to be honest (also mainly to keep consistence between the various RiveScript impls). However I will start look at e.g. ANTLR so we can make an actual grammar/lexer for RiveScript.