AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

Detect user repeat sentences in AIML
 
 

Hi Dear all,

I have some difficulty detecting repeating input sentences. Ex, Assume some users say same thing again and again to see how bot responds.

User : Test
Bot : Some response from random pool
User : Test
Bot : Some other response from random pool
..

I would like if the bot can do following,

User : Test
Bot : Some response from random pool
User : Test
Bot : Why are you saying the same thing?
...

I have searched in the forum but couldn’t find a direct method do achieve this functionality. So I came up with a solution, at least if AIML is checking in * pattern (for unknown input), we have a condition to check for last user input. The user input is kept in a variable using <set> tag. Here is the concept,

<category><pattern>*</pattern>
    <
template>
        <
condition name="userlast">
            <
li value="<star/>">Why are you saying the same thing?l</li>
            <
li>Something from a random pool</li>
        </
condition>
        <
think><set name="userlast"><star></star></set></think>
    </
template>
</
category

The problem is with the value=”<star/>” part as obviously it is invalid. So my question is, how can I check for the user pattern within the conditional value? Or is there any other way to fulfil the requirement I have?

Thanks folks!
smile

 

 
  [ # 1 ]

Hey all,

Just figured out! If anyone is searching for an answer, use the following smile

<category><pattern>*</pattern>
    <
template>
        <
condition name="userlast">
            <
li><value><star/></value>Why are you saying the same thing?l</li>
            <
li>Something from a random pool</li>
        </
condition>
        <
think><set name="userlast"><star></star></set></think>
    </
template>
</
category

 

 

 
  [ # 2 ]

That will only work if no other category matches. You can’t easily do this in native AIML.

 

 
  [ # 3 ]

Steve is correct, but one thing you can do as I have shown in previous posts is to prefix ALL of your patterns with a keyword that the user will never enter and then force your star pattern above to match.  You perform your test and then use SRAI tags to reprocess the input but with your keyword prefixed to the original input.  This allows you to perform initial processing before all other patterns.

I prefix all of my patterns with either XSTATEMENT or XQUESTION followed by the pattern I want to match.  I actually use the generic STAR pattern above to prefix XSYSTEM which then processes a set of XSYSTEM patterns first.  These decide if a pattern is a statement or question and then I prefix the appropriate keyword.  You could perform your test for repeating statements in the initial system topic which could contain other tests you want to perform first as well.

Since it has to search all patterns before not matching and finally hitting your generic STAR pattern it would be best for performance if the client application or web page could prefix the user input with XSYSTEM automatically with each user input instead.

Good luck.

 

 
  login or register to react