According to the sorting of triggers,
For multiple triggers with the same amount of words, sort them by length, and then alphabetically if there are still matches in length.
However, it seems that the sort by character-length and alphabetical order are not yet implemented.
An example set of triggers, this can be evaluated from Try RiveScript Online:
+ * you *
- you_reply
+ * are *
- are_reply
Both of them would match the user input "how are you doing" but the RiveScript answer will be you_reply, the first occurrence in the .rive file (because the triggers are stored as list). Change the order of triggers and you will find it matches the first occurrence. The dependence on ordering of templates in such cases violates the sorting rule stated earlier (in alphabetical order).
Another example of atomic triggers which requires activation of the RS debug mode by setting rs = RiveScript(debug = True) to see the sort order of triggers:
+ hi
- hi there
+ hello
- hello there
The sort order should be: hello then hi because:
-
Length in terms of characters (len("hello")=5, len("hi")=2)
-
Alphabetical order.
However, the order search information shows that sorted list of triggers places hi before hello
You> hello
[RS] Get reply to [localuser] hello
[RS] Checking topic random for any %Previous's.
[RS] There is a %Previous in this topic!
[RS] lastReply: undefined
[RS] Try to match u'hello' against u'hi' (u'^hi$')
[RS] Try to match u'hello' against u'hello' (u'^hello$')
[RS] Found a match!
[RS] Reply: hello there
Bot> hello there
According to the sorting of triggers,
However, it seems that the sort by character-length and alphabetical order are not yet implemented.
An example set of triggers, this can be evaluated from Try RiveScript Online:
Both of them would match the user input
"how are you doing"but the RiveScript answer will beyou_reply, the first occurrence in the.rivefile (because the triggers are stored as list). Change the order of triggers and you will find it matches the first occurrence. The dependence on ordering of templates in such cases violates the sorting rule stated earlier (in alphabetical order).Another example of atomic triggers which requires activation of the RS debug mode by setting
rs = RiveScript(debug = True)to see the sort order of triggers:The sort order should be:
hellothenhibecause:Length in terms of characters (
len("hello")=5,len("hi")=2)Alphabetical order.
However, the order search information shows that sorted list of triggers places
hibeforehello