问题
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