如何使我的机器人按顺序而不是随机地提问?

时间:2018-07-25 15:18:47

标签: xml aiml

当前,我正在使用AIML进行基本的机器人问答功能。请查看以下代码:

<category>
<pattern>RANDOM PICKUP LINE</pattern>
<template>
    <random>
        <li>What is the first thing you have to do when consulting a patient?</li>
        <li>During the consultation, is there other person in the room, such as nurse?</li>
        <li>How can you determine what kind of illness does a patient have? </li>
        <li>When do you use the blood pressure monitor machine?</li>
    </random>
</template>

模式-定义模式以匹配用户在输入时可以输入到Alicebot的模式

template −定义Alicebot对用户输入的响应。

但是,我们无法预测用户将输入什么。我该如何按顺序而不是随机地提出机器人所提出的问题。

我的意思是:这个问题将被依次询问。 (而不是随机的)

User: Hi
Bot: What is the first thing you have to do when consulting a patient?
User: Normally, we will ask he/she what symptoms does he/she have.
Bot: During the consultation, is there other person in the room, such as nurse?
User: No.
Bot: How can you determine what kind of illness does a patient have?
User: Based on their symptoms, I can predict what kind of illness she/he is having.
Bot: When do you use the blood pressure monitor machine?
User: I will decide when should I use the machine after I used stethoscope to listen to patient's heart and lungs.

我尝试删除随机标签,但似乎不起作用。

感谢您的帮助。

3 个答案:

答案 0 :(得分:0)

在aiml中使用它

<aiml>
<category>
<pattern>hi</pattern>
<template>what car gives the best milage in 2018</template>
<category>

<category>
<that>what car gives the best milage in 2018</that>
<pattern>*</pattern>
<template>wrong.who is the richest carmaker?</template>
<category>

<category>
<that>what car gives the best milage in 2018</that>
<pattern>ford</pattern>
<template>you are corrrect.who is the richest carmaker?</template>
<category>

<category>
<that>what car gives the best milage in 2018</that>
<pattern>*</pattern>
<template>wrong.what was the last car company to go out of buisness?</template>
<category>

<category>
<that>wrong.what was the last car company to go out of buisness?</that>

<pattern>bill gord</pattern>
<template>you are corrrect.what was the last car company to go out of buisness?</template>
<category>

<category>
<that>you are corrrect.who is the richest carmaker?</that>

<pattern>bill gord</pattern>
<template>you are corrrect.what was the last car company to go out of buisness?</template>
<category>


</aiml>
the people are are fictional.

答案 1 :(得分:0)

因此,根据您的问题,您正在通过使用 template用于响应,that用于匹配该机器人问您的上一个问题

   <category>
      <pattern>Hi</pattern>
      <template>Do you like comedy movies</template>  
   </category>

   <category>
      <pattern>YES</pattern>
      <that>Do you like comedy movies</that>
      <template>Nice, I like comedy movies too.</template>
   </category>

   <category>
      <pattern>NO</pattern>
      <that>Do you like comedy movies</that>
      <template>Ok! But I like comedy movies.</template>
   </category> 

</aiml>

source

答案 2 :(得分:0)

尽管上面的示例将起作用,但它们不必要地冗长。您可以在原始类别中进行一些修改,以实现此目的:

<category>
<pattern>RANDOM PICKUP LINE</pattern>
<template>
<condition name="qnum">
    <li value="1">What is the first thing you have to do when consulting a patient?<think><set name="qnum">2</set></think></li>
    <li value="2">During the consultation, is there other person in the room, such as nurse?<think><set name="qnum">3</set></think></li>
    <li value="3">How can you determine what kind of illness does a patient have?<think><set name="qnum">4</set></think></li>
    <li value="4">When do you use the blood pressure monitor machine?<think><set name="qnum">1</set></think></li>
    <li><think><set name="qnum">1</set></think><srai>RANDOM PICKUP LINE</srai></li>
</condition>
</template>

我们需要设置一个谓词来跟踪问题编号,我称之为“ qnum”。现在,我们使用条件查找“ qnum”的值并显示适当的响应。然后,我们增加“ qnum”以在下一次调用类别时显示下一个问题。如果我们到达问题的结尾,请将“ qnum”重置为1,以便重新开始。

底部的

  • 用于初始呼叫。尚未设置“ qnum”,因此我们将其初始化为1,然后再次调用类别以显示第一个问题。

  • 相关问题