我正在尝试使用带有Python的aiml构建聊天机器人 [英] Am trying to built a chat bot using aiml with python

查看:335
本文介绍了我正在尝试使用带有Python的aiml构建聊天机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

import aiml
import os
kernel = aiml.kernel()
if os.path.isfile("bot_brain.brn"):
    kernel.bootstrap(brainFile = "bot_brain.brn")
else:
    kernel.bootstrap(learnFiles = "std-startup.xml", commands = "load aiml b")
    kernel.savebrain("bot_brain.brn")
while True:
    print kernel.respond(raw_input("Enter Your Message")).strip()
aiml.kernel()

它抛出类似

回溯(最近通话最近): 在第3行的文件" init .py"中 内核= aiml.kernel() AttributeError:模块"对象没有属性内核"

Traceback (most recent call last): File "init.py", line 3, in kernel = aiml.kernel() AttributeError: 'module' object has no attribute 'kernel'

推荐答案

aiml.kernel()应该是aiml.Kernel()

aiml.kernel() should be aiml.Kernel()

请注意,aiml软件包仅适用于Python2.GitHub上的Py3kAiml是Python 3的替代方案.您还参考了此帖子.

Note the aiml package only works with Python 2. Py3kAiml on GitHub is a Python 3 alternative. You also refer to this post.

这篇关于我正在尝试使用带有Python的aiml构建聊天机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆