我正在编写以下AIML代码。
<aiml>
<category>
<pattern>test</pattern>
<template>This is a test to try the third possible input. Yes / No ? </br>
</template>
</category>
<category>
<pattern>Yes</pattern>
<that>This is a test to try the third possible *</that>
<template>Hey!. You have typed YES!</template>
</category>
<category>
<pattern>No</pattern>
<that>This is a test to try the third possible *</that>
<template>Hey!. You have typed No!</template>
</category>
<category>
<pattern>*</pattern>
<that>This is a test to try the third possible *</that>
<template>BINGO!!!!</template>
</category>
</aiml>
我想看看&#34; Bingo !!!&#34;作为用户输入除“是”或“否”之外的任何内容的响应。
<pattern>*</pattern>
单独使用时效果很好,但不在这里。我在哪里做错了?
答案 0 :(得分:0)
某些AIML库要求pattern
值为大写(即使对于不强制它的实现,这也是很好的做法)。所以对我来说,下面的代码按预期工作(在PyAIML下测试):
<aiml>
<category>
<pattern>TEST</pattern>
<template>This is a test to try the third possible input. Yes / No ? <br /></template>
</category>
<category>
<pattern>YES</pattern>
<that>THIS IS A TEST TO TRY THE THIRD POSSIBLE *</that>
<template>Hey!. You have typed YES!</template>
</category>
<category>
<pattern>NO</pattern>
<that>THIS IS A TEST TO TRY THE THIRD POSSIBLE *</that>
<template>Hey!. You have typed No!</template>
</category>
<category>
<pattern>*</pattern>
<that>THIS IS A TEST TO TRY THE THIRD POSSIBLE *</that>
<template>BINGO!!!!</template>
</category>
</aiml>
输出:
> test
This is a test to try the third possible input. Yes / No ?
> yes
Hey!. You have typed YES!
> test
This is a test to try the third possible input. Yes / No ?
> no
Hey!. You have typed No!
> test
This is a test to try the third possible input. Yes / No ?
> Foo
BINGO!!!!
>
您可以尝试使用<that>
代替<topic>
代码,例如:
<aiml>
<category>
<pattern>TEST</pattern>
<template>
This is a test to try the third possible input. Yes / No ? <br />
<think><set name="topic">THREE OPTIONS</set></think>
</template>
</category>
<topic name="THREE OPTIONS">
<category>
<pattern>YES</pattern>
<template>Hey!. You have typed YES!</template>
</category>
<category>
<pattern>NO</pattern>
<template>Hey!. You have typed No!</template>
</category>
<category>
<pattern>*</pattern>
<template>BINGO!!!!</template>
</category>
</topic>
</aiml>