当前位置:   article > 正文

python开发聊天机器人,我正在尝试使用带有Python的aiml构建聊天机器人

kernel.bootstrap(brainfile

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.

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/374685
推荐阅读
相关标签
  

闽ICP备14008679号