In #67 the sorting algorithm was refactored and I found a rather visible breakage from it: in the example bot I wasn't able to match the hello triggers:
You> hello bot
Bot> Please go on.
You> hi
Bot> I'm not sure I understand you fully.
You> my name is noah
Bot> Noah, nice to meet you.
You> hello
Bot> Please go on.
In the previous state of the master branch (commit 405e391) it gives the expected result:
You> hello bot
Bot> Hi. What seems to be your problem?
You> hello
Bot> How do you do. Please state your problem.
I made this local change to my rivescript/interactive.py to print the sorted lists for both versions:
diff --git a/rivescript/interactive.py b/rivescript/interactive.py
index 3b67727..5cf9510 100644
--- a/rivescript/interactive.py
+++ b/rivescript/interactive.py
@@ -200,6 +200,12 @@ def interactive_mode():
bot.load_directory(args.path)
bot.sort_replies()
+ topics = sorted(bot._sorted['topics'].keys())
+ for topic in topics:
+ print("Topic:", topic)
+ for trigger in bot._sorted['topics'][topic]:
+ print("\t", trigger[0])
+
# Interactive mode?
if args.json:
# Read from standard input.
I've attached the outputs of the above sort lists:
broken-sort.txt
good-sort.txt
Here is a snippet of the buggy version's output around the relevant trigger:
i am *
everyone *
- *
i am (sad|unhappy|mad|angry|pissed|depressed) [*]
i am (happy|excited|glad) [*]
+ (hello|hi|hey|howdy|hola|hai|yo) [*]
(what|who|when|where|how) [*]
my (girlfriend|boyfriend)* name is *
So it seems the bare wildcard * took a higher precedence over triggers that contained alternatives and optional *'s.
I also saw similar cases in the output of the triggers not being sorted the best: in the topics used for the RPG game demo, the _ * trigger was at the very bottom (below *) when they should've been in the opposite order (_ * > *).
I'm not planning a new official release too soon, so I'll leave PR #67 merged for now and hopefully these last couple bugs can be resolved. If I do need to make a new release before then I'll have to revert #67 and try again later.
In #67 the sorting algorithm was refactored and I found a rather visible breakage from it: in the example bot I wasn't able to match the
hellotriggers:In the previous state of the
masterbranch (commit 405e391) it gives the expected result:I made this local change to my
rivescript/interactive.pyto print the sorted lists for both versions:I've attached the outputs of the above sort lists:
broken-sort.txt
good-sort.txt
Here is a snippet of the buggy version's output around the relevant trigger:
So it seems the bare wildcard
*took a higher precedence over triggers that contained alternatives and optional*'s.I also saw similar cases in the output of the triggers not being sorted the best: in the topics used for the RPG game demo, the
_ *trigger was at the very bottom (below*) when they should've been in the opposite order (_ *>*).I'm not planning a new official release too soon, so I'll leave PR #67 merged for now and hopefully these last couple bugs can be resolved. If I do need to make a new release before then I'll have to revert #67 and try again later.