【问题标题】:<that> and <topic> tags cause no matches<that> 和 <topic> 标签导致不匹配
【发布时间】:2021-02-16 19:12:41
【问题描述】:

我正在尝试学习 AIML,并使用以下 3 个文件构建了一个简单的聊天机器人:

std-startup.xml

<aiml version="1.0.1" encoding="UTF-8">
<category>
    <pattern>
        LOAD AIML B
    </pattern>
    <template>
        <learn>key.aiml</learn>
    </template> 
</category>
</aiml>

key.aiml

<aiml version="2.0" encoding="UTF-8">

<category>
    <pattern>
        CAN NOT UNLOCK
    </pattern>
    <template>
        What are you trying to unlock? 
    </template>
</category>

<category>
    <pattern>* DOOR</pattern>
    <that>What are you trying to unlock?</that>
    <template>
        <think><set name="door"><star/></set></think>
        <condition name="door" value="apartment">
            <think><set name="topic"><star/></set></think>
            Is there any video on the screen? 
        </condition>
        <condition name="door" value="entrance">
            <think><set name="topic"><star/></set></think>
            Is there a green light? 
        </condition>    
    </template>
</category>

<topic name="apartment">
<category>
    <pattern>yes</pattern>
    <template>
        topic set to apartment  
    </template>
</category>
</topic>

<topic name="entrance">
<category>
    <pattern>yes</pattern>
    <template>
        topic set to entrance  
    </template>
</category>
</topic>

</aiml>

简单的.py

import aiml

kernel = aiml.Kernel()
kernel.learn("std-startup.xml")
kernel.respond("load aiml b")

while True: 
    input_text = input(">Tenant: ")
    response = kernel.respond(input_text)
    print(">Bot: ", response)

但是,除非我注释 和 标签,否则上述方法不起作用并且不会返回“* DOOR”和“yes”的匹配项。我按照教程到了一个 T,但我不明白为什么它说 WARNING: No match found for input: yes

请帮助我理解我的错误。

【问题讨论】:

    标签: python nlp chatbot aiml


    【解决方案1】:

    您不应该在 标记中包含标点符号。漏掉问号应该没问题。

    【讨论】:

    • 非常感谢!这对我有用。在开始项目之前,我已经阅读了您的帖子,这是一个巨大的帮助!谢谢你的工作。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-03-17
    • 1970-01-01
    • 2015-04-10
    • 2021-09-03
    • 1970-01-01
    • 2017-12-26
    • 1970-01-01
    相关资源
    最近更新 更多