包含相同模式的多个 AIML。如何根据用户偏好获取它

Multiple AIML containing same patterns. How to fetch it according to users preference

您好! 我有一个聊天机器人,其中包含 n 个 AIML 文件。每个 AIML 文件都与不同的主题相关。但它可能包含相同的模式,导致在从聊天机器人获得回复时发生冲突。我想确定用户正在寻找哪个主题。 那么如何根据这个要求配置我的聊天机器人呢?

AIML 文件 1

<category>
      <pattern>ABC</pattern>
      <template>abcdefghijklmnopqrstuvwxyz</template>
</category>

AIML 文件 2

<category>
      <pattern>ABC</pattern>
      <template>1234567890ABCD</template>
</category>

两者都与一个聊天机器人相关联。所以作为最终用户,我想从 AIML file 2 那里得到答案。如何使用 program-o

让我的聊天机器人了解我的需求

我认为您可能需要查看 topic 标签。

The concept is that the botmaster uses the <set_topic> tags to set the current topic being discussed. Once the topic is set, when the client types in a statement for ALICE to find a response for, the categories defined within the <topic> tags matching the current topic will be searched first-- before any of the non-topic categories, or the default categories. If there is not a matching category defined in the current topic, then any categories that are not defined in topic tags are searched. As mentioned before, you can create categories with identical <pattern> phrases in different topics, each with different responses that cater to the current topic.

粗体是我的重点。

尽管 AIML 解释器以不同的方式实现主题,但您可以按照上一个答案中的描述对主题执行此操作,具体取决于您使用的是 Pandorabots、Alice 还是 AIML 的 v1 或 v2。

换个角度看这个问题:当您将更多类别和文件加载到聊天机器人时,它们需要更加具体。因此,如果可能,请根据他们回答的问题类型使您的 ABC 模式更加具体。

另一种类似于主题的方法(但不使用 AIML 解释器的主题处理)是将先前类别中的全局谓词设置为感兴趣的主题。假设您有一个全局 属性 "subject",您在其他类别中将其设置为 "text" 或 "numbers"。然后,您可以按如下方式合并 ABC 模式:

<category>
  <pattern>ABC</pattern>
  <template>
    <condition>
      <li name="subject" value="text">abcdef...</li>
      <li name="subject" value="numbers">0123456789</li>
      <li>?</li>
    </condition>
  </template>
</category>