Skip to content

No alphabetical sort for triggers of same type and number of words #66

Description

@htdinh

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:

  1. Length in terms of characters (len("hello")=5, len("hi")=2)

  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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions