簡體   English   中英

如何在python aiml中插入新模式

[英]how to insert new patterns in python aiml

你好,我正在嘗試使用python( aiml庫 )在aiml中插入新模式 。我正在學習本教程 ,我可以使用ALICE chatbot的預定義模式並使用template標簽更改其答案,但是當我插入不是在ALICE聊天機器人中,程序給出了此錯誤警告:找不到與輸入“”匹配的內容 ,請幫助是否有辦法使用python aiml庫插入新模式?

下面是我的chatbot.py文件

    import aiml
    import sys

    mybot = aiml.Kernel()
    mybot.setBotPredicate('name','chefbot')
    mybot.learn('sample.aiml')

    while True:
       if input == "quit":
       sys.exit(0)
       input_text = input("> ")
       response = mybot.respond(input_text)
       print(response)

這是我的sample.aiml文件

<aiml version="1.0">
<category>
<pattern>WHY CAN NOT YOU EAT</pattern>
<template>Actually I eat only electricity.</template>
</category>
<category>
<pattern>EACH YEAR IN PRO BASEBALL THE *</pattern>
<template>The Gold Glove.</template>
</category>
<category>
<pattern>hello</pattern>
<template>Hello my friend how are you,i am chefbot</template>
</category>
<category>
<pattern>WHAT IS YOUR NAME</pattern>
<template>My name is chefbot</template>
</category>
<category>
<pattern>YOU CAN DO BETTER</pattern>
<template>Get that cake for me</template>
</category>
</aiml>

它可以響應UpperCase中的模式 ,因為它們是在ALICE bot中預定義的,但是會在我在Lowercase中定義的模式上顯示錯誤。 提前致謝..

標簽之間的所有文本均應為大寫

每次修改目標文件時,都需要重新啟動機器人

ķ

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM