Search code examples
xmlchatbotaiml

How can I have more than one Wildcard in a pattern


I am working on a AI chat bot in Pandoabots using XML in AIML and I am getting stuck on how you would have more than one wildcard in a pattern without it breaking.

Here I am trying to store a value like "where" before Cardiff and after Cardiff I want the program to pick up on any keywords like "please","?" and "bot". However when I do this is displays the default value which is "I have no answer for that. However not all the questions will have "please" or "?" at the end.

 <category>
     <pattern>* Cardiff *</pattern>
     <template><think><set name = "place"><star/></set><set name = "others"><star/></set></think>
         <condition name = "place">
             <li name ="Where">In wales</li>
         </condition>
     </template> 
 </category>

I have been doing research on how to tackle this problem and I have not found a solution to it.


Solution

  • The * wildcard indicates at least 1 word and so won't be triggered if someone says, "Where is Cardiff", as there isn't 1 or more words after Cardiff. You need to replace this with the # wildcard which indicates zero or more words, so "Where is Cardiff" and "Where is Cardiff please" will activate the category. You don't need to know the value of the second wildcard.

    Also, you need to change your condition to check for "where is" rather than just "where"

     <category>
         <pattern>* Cardiff #</pattern>
         <template>
             <think><set name="place"><star/></set></think>
             <condition name="place">
                 <li name ="Where is">In wales</li>
             </condition>
         </template> 
     </category>