AIML - 上下文 - 为什么上下文不是在所有情况下都具有最高优先级?

AIML - context - why does context not have highest priority in all cases?

在使用 AIML 上下文时(通过 ),我遇到了一些我无法解释的对话。 我希望(那个)上下文优先于其他任何内容。

下面我先展示一下脚本。然后我展示一些对话。我在响应后面用 // 标记了意外部分。

我将此 Aiml 文件添加到标准的 ALICE 对话中。

脚本:

<category><pattern>STEP 1</pattern>
  <template>Step 2</template>
</category>
<category><pattern>YES</pattern><that>STEP 2</that>
  <template>step 3</template>
</category>
<category><pattern>NO</pattern><that>STEP 2</that>
  <template>step 3</template>
</category>
<category><pattern>*</pattern><that>STEP 2</that>
  <template>step 3</template>
</category>
<category><pattern>*</pattern><that>STEP 3</that>
  <template>Step 4! and you typed '<star/>'</template>
</category>

在接下来的对话中,我用 // ?

标记了意外响应
Human : step 1
Robot : Step 2
Human : yes
Robot : step 3
Human : yes
Robot : Step 4! and you typed 'yes'
Human : step 1
Robot : Step 2
Human : no
Robot : step 3
Human : no
Robot : So. // ? I expected here step 4
Human : step 1
Robot : Step 2
Human : any
Robot : any is a name. // ? I expected here step 3

你能解释一下这两种意想不到的对话流程吗?

<that> 元素优先于同一模式级别 的其他模式。我不知道您使用的是 AIML v1 还是 v2,但从广义上讲,有 3 个级别的模式 [但请参阅下面的注释]

  1. 最重要的级别 = 包含下划线通配符 (_) 的模式
  2. 中级 = 没有任何通配符的原子模式
  3. 最低级别 = 包含星号通配符 (*) 的模式

您的意外响应是因为有更高优先级的 ALICE 响应。例如,当机器人回复 "step 3" 而人类回答 "no" 时,您希望 <pattern>*</pattern><that>STEP 3</that> 类别生效。但是如果有更高级别的 ALICE 响应(例如 <pattern>NO</pattern><pattern>STEP _</pattern>),ALICE 响应将对您的第 3 级类别 <pattern>*</pattern><that>STEP 3</that> 生效。查找 ALICE 类别的最快方法就是询问 "NO" 并查看机器人的回复。您也可以搜索 ALICE 文件,但这会非常耗时。

[note] 在 AIML v2 中至少有两个额外级别:下划线通配符之上的级别 0,以及使用模式边集的级别 2.5。然而,更简单的 AIML v1 级别解释了您的异常情况。