首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AIML -外卡标签

AIML -外卡标签
EN

Stack Overflow用户
提问于 2018-04-05 14:09:29
回答 1查看 287关注 0票数 1

我正在编写下面的AIML代码。

代码语言:javascript
复制
<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>

我想看看“宾果!”作为响应,当用户输入除“是”或“否”之外的任何内容时。

代码语言:javascript
复制
<pattern>*</pattern>

当我单独使用它时,效果很好,但这里不行。我在哪里搞错了?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-04-05 18:07:42

一些AIML库要求pattern值大写(这是一个很好的实践,即使对于不强制它的实现也是如此)。因此,对我来说,以下代码按预期工作(在PyAIML下测试):

代码语言:javascript
复制
<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>

输出:

代码语言:javascript
复制
> 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>,例如:

代码语言:javascript
复制
<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>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49674463

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档