1

样本:

User: How old are you and where do you live ?
Alice: I'm 7 months old. I live on earth.

我的尝试:

<category>
    <pattern>WHERE DO YOU LIVE</pattern>
    <template>I live on earth.</template>
</category>

<category>
    <pattern>HOW OLD ARE YOU</pattern>
    <template>I'm 7 months old.</template>
</category>

上面的AIML代码只有我分开问这两个问题才能回复。

4

2 回答 2

1

通过深入研究AIML 语法,我终于找到了一个带有<srai>标签的解决方案:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE inline_dtd[
<!ENTITY nbsp "&#160;">
]>
<aiml version="2.0">
    <category>
        <pattern>WHERE DO YOU LIVE</pattern>
        <template>I live on earth.</template>
    </category>

    <category>
        <pattern>HOW OLD ARE YOU</pattern>
        <template>I'm 7 months old.</template>
    </category>

    <category>
        <pattern>HOW OLD ARE YOU AND WHERE DO YOU LIVE</pattern>
        <template>
            <srai>HOW OLD ARE YOU</srai>
            &nbsp;
            <srai>WHERE DO YOU LIVE</srai>
        </template>
    </category>
</aiml>
于 2019-08-12T08:59:51.263 回答
1

您也可以使用通配符来改善这一点。现在我们可以回答诸如“你好吗,伦敦在哪里”之类的问题

<category>
    <pattern>HOW _ AND WHERE *</pattern>
    <template>
        <srai>HOW <star/></srai>
        <srai>WHERE <star index="2"/></srai>
    </template>
</category>
于 2019-11-03T16:39:58.820 回答