【问题标题】:Using conditional tags in AIML在 AIML 中使用条件标签
【发布时间】:2017-10-09 21:58:58
【问题描述】:

我正在尝试在我的 AIML 文件中添加条件标记功能。 我正在使用带有 PyAIML 和 pb_py 库的 python 脚本。

在我当前的实现中,我设置了它,以便我可以在我的 python 脚本中动态设置谓词值,以便条件标记为“语音”或“文本”:

<!-- 5 Legacy -->
<category><pattern>ARE YOU NAMED AFTER *</pattern><template><srai>legacyresponse</srai></template></category>
<category><pattern>WHO ARE YOU NAMED AFTER</pattern><template><srai>legacyresponse</srai></template></category>
<category><pattern>LEGACYRESPONSE</pattern>
<template>
<condition name = "inputtype">
    <li value = "speech">Some response</li>
    <li value = "text">Some text response.</li>
</condition>
<srai>promptuser</srai>
</template>
</category>

在我的 AIML 文件中,我实现了多个响应功能,如下所示:

<category><pattern>_ YOUR DAD *</pattern><template><srai>parentsresponse</srai></template></category>
<category><pattern>PARENTS</pattern><template><srai>parentsresponse</srai></template></category>
<category><pattern>PARENTS</pattern><template><srai>parentsresponse</srai></template></category>
<category><pattern>PARENTSRESPONSE</pattern>
<template>
<random>
<li>Response 1</li>
<li>Response 2</li>
<li>Response 3</li>
</random>
<srai>promptuser</srai>
</template>
</category>

我希望同时具有多重响应和条件功能,例如,如果我传入“语音”条件,它会选择

  • 标签,其值设置为 'speech' 或
  • 未指定值的标记:
    <category><pattern>LEGACYRESPONSE</pattern>
    <template>
    <condition name = "inputtype">
        <li value = "speech">Some Speech only response</li>
        <li>Some speech or text response</li>
        <li value = "text">Some text only response.</li>
    </condition>
    <srai>promptuser</srai>
    </template>
    </category>
    

    任何帮助将不胜感激?

  • 【问题讨论】:

    • 抱歉,我仍然无法理解您的问题。您已经使用 Python 将“inputtype”设置为“Speech”,现在您想要来自 AIML 的 2 个响应?或者您想要语音响应或没有价值时?

    标签: python artificial-intelligence chatbot aiml


    【解决方案1】:

    我没有得到您的全部要求。但据我了解,您遇到了条件标签的问题。

    每当用户选择“语音”或“文本”时,请将“输入类型”设置为相应的值。如果用户没有选择其中任何一个,则“inputtype”的值为“unknown”。

    <condition name="inputtype">
        <li value="speech">Your stuff </li>
        <li value="text">Your stuff </li>
        <li value="unknown">Your stuff </li>
    </condition>
    

    【讨论】:

      【解决方案2】:

      您可以查看以下示例 AIML 代码并在您的文件中进行相应更改。

      <?xml version="1.0" encoding="UTF-8"?>
      <aiml version="1.0">
      <category>
          <pattern>WHAT ABOUT MOVIES</pattern>
          <template>
          I love talking about movies too!
          <think><set name="topic">MOVIE</set></think>
          <br/>Did you like comedy movies?
          </template>
      </category>
      <topic name="MOVIE">
          <category>
              <pattern>YES</pattern>
              <that>* LIKE COMEDY  *</that>
              <template>You seems an interesting person!</template>
          </category>
          <category>
              <pattern>NO</pattern>
              <that>* LIKE COMEDY  *</that>
              <template>You seems a boring person!</template>
          </category>
      </topic>
      </aiml>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-01-16
        • 2018-11-19
        • 2019-11-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多