Disclaimer: So, a post that reflects a different direction from my usual photography or self-reliance posts. If you are one of my usual visitors, you can skip this one; it pertains to my software/A.I/Chatbot side-project only. Sorry!
I am busy working on my AIML (Artificial Intelligence Markup Language) based chatbot, Odorware, and while working on a help response, I realised something. My context was not being detected by the bot, and my understanding of AIML is obviously lacking greatly. The use of topics and context is of utter importance when it comes to knowing where the conversation with an A.I is going.
A Quick Human Example: If you are talking to a colleague about how much the office coffee-machine is changing your life, you are setting a context implicitly with the colleague. The context is the office coffee-machine. After a few minutes of silence, you could then randomly blurt out something like “But it probably uses a lot of electricity”. Your colleague will (should) know that you are referring to the previous, almost stale, context. Of course, if they engage in a different conversation with someone else, the context changes; you can no longer say random things without risking confusion or a ‘we moved on, dude’ kind of retort.
The AIML <that> and <topic> tags do that job, and stores or marks the topic and context as someone talks to the bot. I am preaching to the choir here, and it’s not what this post is about, so back to the problem. Remember that we are no hardcoding an if-else here, but setting up the botbrain to handle context for specific topics, and we rely on it to keep up!
In the preceding category, the bot gives the visitor some advice, and then asks if this advice was useful. The context is set to ‘advice about abc’ for instance. The following category’s <that> tag then checks for the “last sentence in the previous uttering” of the bot, and fails.
Look at the above. Anything along the lines of “how do i scratch my butt” will match that pattern, and the bot will go into a little monologue, ending with “Is this helpful?”. That is basically, in my opinion the bot’s last utterance, and the category below it should match it in the <that> tag. However, IT DOESN’T!.
The “last sentence” is not IS THIS HELPFUL but is preceding with less-than, greater-than and forwardslash entities. This causes the context to fail. Removing line 16, fixes the issue, and the last utterance is just IS THIS HELPFUL. Using split, adding BR tags or calling an external category with <srai> doesn’t fix it either.
I don’t know why, or how to do this right. The last sentence now has no delay, no split and no line break before it. It’s the only solution I could find. I would love to hear some comments about this from anyone?
It works for me now, at least. My actual code is a bit more sophisticated than that, as it includes more conditions and topics, but the issue persists. What kind of pattern matching should be done in the <that> to essentially ignore all noise before the last-sentence spoken in the previous category?
I have not tested this on BotLibre yet, but it definitely exists on my PandoraBots instance.