keiffster / program-y

Python 3.x based AIML 2.0 Chatbot interpreter, framework, related programs and knowledge files
https://keiffster.github.io/program-y/
Other
349 stars 136 forks source link

Bug in pattern parser where the star index of the words will change #296

Open EdvinJakobsson opened 3 years ago

EdvinJakobsson commented 3 years ago

I have tried to pinpoint when this bug occurs, and I have found one simple example. I have seen the bug trigger in other instances as well though, and it has become a major headache to try to sidestep it in our project.

Example pattern:

    <category>
        <pattern>^ <iset words="SHOW, GIVE"/> ^ VIDEO ^ <iset words="INSTALL, REPLACE"/> <iset words="RADIO, ANTENNA"/></pattern>
        <template>
            1:<star index="1"/> <br/>
            2:<star index="2"/> <br/>
            3:<star index="3"/> <br/>
            4:<star index="4"/> <br/>
            5:<star index="5"/> <br/>
            6:<star index="6"/> <br/>
        </template>
    </category>

In this pattern the install/replace word should be retrievable as "star index=5" and the radio/antenna as "star index=6", and when this is the only pattern in the bot it works fine for an example question: "please show me a video on how to install radio ".

However, if I add a second pattern:

<category>
        <pattern>^ SHOW ^ VIDEO ON CATS</pattern>
        <template>
            CAT VIDEO
        </template>
    </category>

then even though this pattern will not match the example question above, it will affect how the words are indexed in the first pattern (in this case it will kind of forget about all words before the "show"). All words are hence indexed one step earlier than they should, leaving the radio/antenna word to be retrievable as "star index=4" and radio/antenna as "star index=5", as seen in the image attached. Also note that using the other word in the iset, "give", the pattern still functions as normal. p4

I will also attach the log from when asking the three questions in the image, when both patterns are loaded (and no other patterns)

programy-log-edvin.log