【问题标题】:AIML Parser ExampleAIML 解析器示例
【发布时间】:2020-08-07 20:06:47
【问题描述】:

我需要一些帮助来使用下面的示例来理解 AIML 模板,感谢您的帮助以使该模板正常工作。

这些是我尝试处理的一些示例输入,以及我想通过 AIML 解析生成的输出。

输入:sale abc
输出:销售 ABC

输入:销售额 abc
输出:销售 ABC

输入:产品 abc 的销售
输出:销售 ABC

输入:销售产品 abc
输出:销售 ABC

输入:产品 abc 的销售额是多少
输出:销售 ABC

输入:产品 abc 的平均销售额是多少
输出:AVG SALES ABC

输入:产品 abc 的平均销售额是多少 输出:AVG SALES ABC

输入:产品 abc 最近 30 天的平均销售额是多少 输出:AVG SALES ABC 30

输入:产品 abc 最近 30 天的平均销售额是多少 输出:AVG SALES ABC 30

我一直试图从这样的事情开始,但由于我对这个工具缺乏明确性,这似乎进展不顺利。

 <category><pattern>
    # <set>numbers</set>  <set>days</set>  <set>average</set> sales <set>prepositions</set> *</pattern>
  <template>SALES <star index="1"/>,<star index="2"/>,<star index="3"/>,<star index="4"/>,<star index="5"/>,<star index="6"/> </template>
  </category>

其中数字集定义> 1,2,3,4,5..... 100

天设置定义>天,天

平均集定义>平均,平均,平均

介词集定义> of

谢谢!

【问题讨论】:

    标签: chatbot aiml


    【解决方案1】:

    您应该使用通配符而不是集合来执行此操作。您需要的唯一集合是针对您的产品的,并且可能是针对天数的集合。

    此类别是对您前 4 个查询的回复:

    <category>
        <pattern>SALE <set>products</set></pattern>
        <template>
            SALES <star/>
        </template>
    </category>
    

    我们现在可以在 中使用通配符来调用主类别:

    <category>
        <pattern>SALES ^ <set>products</set> ^</pattern>
        <template>
            <srai>SALE <star index="2"/></srai>
        </template>
    </category>
    
    <category>
        <pattern>SALE ^ <set>products</set> ^</pattern>
        <template>
            <srai>SALE <star index="2"/></srai>
        </template>
    </category>
    
    <category>
        <pattern>WHAT IS THE SALE ^ <set>products</set> ^</pattern>
        <template>
            <srai>SALE <star index="2"/></srai>
        </template>
    </category>
    

    此类别处理您接下来的 2 个查询:

    <category>
        <pattern>WHAT IS ^ AVERAGE SALE ^ <set>products</set> ^</pattern>
        <template>
            AVG SALES <star index="3"/>
        </template>
    </category>
    

    我们可以用它来表示 AVG 意味着 AVERAGE。你也可以把它放在你的 normal.substitutions 文件中。

    <category>
        <pattern>_ AVG *</pattern>
        <template>
            <srai><star/> average <star index="2"/></srai>
        </template>
    </category>
    

    最后,这个类别会处理您最近的 2 个查询。

    <category>
        <pattern>WHAT IS ^ LAST * DAY ^ AVERAGE SALE ^ <set>products</set> ^</pattern>
        <template>
            AVG SALES <star index="5"/> <star index="2"/>
        </template>
    </category>
    

    【讨论】:

    • 感谢史蒂夫,我正在尝试使用您的示例。但是我不能拥有一组来自大宇宙的产品,我只想选择那个令牌,还有任何内置支持来识别用户输入中的日期吗?再次感谢您的帮助。
    • 在这种情况下,您需要在您的模式中加入产品一词,并祈祷用户说“产品”。 SALE OF PRODUCT * 关于日期的第二个问题似乎与这个,但如果你发布一个新问题,我会看看。
    猜你喜欢
    • 2011-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-17
    • 2012-01-29
    • 2011-06-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多