How can I have more than one Wildcard in a pattern

空扰寡人 提交于 2019-12-13 03:55:00

问题


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.


回答1:


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>


来源:https://stackoverflow.com/questions/58890611/how-can-i-have-more-than-one-wildcard-in-a-pattern

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!