赞
踩
AIML全名为Artificial Intelligence Markup Language(人工智能标记语言),是一种创建自然语言软件代理的XML语言,是由RichardS. Wallace 博士和Alicebot开源软件组织于1995-2000年间发明创造的。AIML是一种为了匹配模式和确定响应而进行规则定义的 XML 格式。
// 安装pip install aiml # -*- coding: utf-8 -*- import aiml import sys import os def get_module_dir(name): print("module", sys.modules[name]) path = getattr(sys.modules[name], '__file__', None) print(path) if not path: raise AttributeError('module %s has not attribute __file__' % name) return os.path.dirname(os.path.abspath(path)) //这个地方我就遇到了一个问题 安装完aiml之后 无法正确的识别路径 //解决的方法是在Python的安装路径下如D:\Python-3.7.3\Lib\site-packages //里面找到aiml 然后把botdata下的文件直接复制到桌面 alice_path = get_module_dir('aiml') + '\\botdata\\alice' os.chdir(alice_path) # 切换到语料库所在工作目录 alice = aiml.Kernel() # 创建机器人alice对象 alice.learn("startup.xml") # 加载...\\botdata\\alice\\startup.xml alice.respond('LOAD ALICE') # 加载...\\botdata\\alice目录下的语料库 while True: message = input("Enter your message >> ") if("exit" == message): exit() response = alice.respond(message) # 机器人应答 print(response)
报错:
解决:
解决的方法是在Python的安装路径下如D:\Python-3.7.3\Lib\site-packages
里面找到aiml 然后把botdata下的文件直接复制到桌面
问题:
解决:
说是没有Kernel()这个属性,其实是有的 ,并且正确加载了,目前我的理解是可能aiml的版本问题,但是运行完之后会在桌面生成一个__pycache__的文件,这里就是aiml了
你可以问她一些问题,当然,你可以在\botdata\alice里面加入更多的东西,让她更加聪明
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。