Am trying to built a chat bot using aiml with python

走远了吗. 提交于 2019-12-11 06:06:43

问题


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()

It is throwing an error like

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


回答1:


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

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



来源:https://stackoverflow.com/questions/43954498/am-trying-to-built-a-chat-bot-using-aiml-with-python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!