赞
踩
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'
解决方案
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.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。