2

我想制作一个聊天机器人,所以我的疑问是如何以多种方式响应目标中的单一模式?例如,如果用户询问下一步是什么,聊天机器人应该响应步骤 1,如果他再次询问下一步是什么,它应该响应步骤 2。

4

4 回答 4

2

您可以在模板中使用“that”标签,它会记住最后一个 bot 语句并相应地回答,尽管这只会为您提供一个级别的控制。如果您想要更多级别,更好的方法是使用“think”标签设置主题,然后定义将首先使用的主题特定模板。

于 2015-03-27T10:26:57.367 回答
0

要对单个 进行多个响应<pattern>,您可以使用<random>and<li>标签:

<category>
         <pattern>WHATS NEXT</pattern>
         <template><random>
             <li>Step 1</li>
             <li>Step 2</li>
         </random></template>
</category>

但是,响应将随机生成,而不是按特定顺序生成。

例如,如果用户输入“下一步是什么?” 第一次,响应可能是“Step 1”,下次用户输入相同的关键字时,响应可能仍然是“Step 1”。

于 2017-01-21T06:59:26.680 回答
0

First you need a category that knows the steps, and returns the answer in a defined format. In my example the format is

MAKE TOAST STEP * *

where the first star is the step number and the second star represents the remainder of the returned text. Here is the category:

<category>
         <pattern>MAKING TOAST STEP *</pattern>
         <template>
             <set var="step"><star/></set>
             <condition var="step">
                 <li value="1">Make toast step 1, get some bread</li>
                 <li value="2">Make toast step 2, put the bread in the toaster</li>
                 <li value="3">Make toast step 3, wait until it pops up</li>
                 <li>Make toast step 4, eat the toast</li>
             </condition>
         </template>
</category>

Then you need a category that calls the next step but only if the previous answer was a toast-making question. This category uses the that tag to ensure it is activated only during the toast making conversation. It uses thatstar to get the previous step number, then adds one to the step number:

<category>
         <pattern>WHAT IS NEXT</pattern>
         <that>MAKE TOAST STEP * *</that>
         <template>
             <set var="step"><calculate><thatstar/>+1</calculate></set>
             <srai>MAKING TOAST STEP <get var="step"/></srai>
         </template>
</category>

Then you need a category to kick off the whole sequence:

<category>
         <pattern>HOW DO I MAKE TOAST</pattern>
         <template>
             <srai>MAKING TOAST STEP 1</srai>
         </template>
</category>

The caveats with this approach are (1) it uses the calculate tag which is not standard AIML but should be coded quite easily. (2) It uses AIML v2 elements such as variables used with get and set. (3) I have not tested it, but I am confident the process should work.

于 2017-02-13T13:47:48.853 回答
0
  <category> 
      <pattern>TEST SPLIT</pattern> 
      <template> 
        I don't want to talk about that now. 
        <split/> 
        I would rather talk about you. 
      </template> 
    </category>

<split/> 输出 参考

于 2019-07-22T14:51:34.140 回答