中文聊天机器人
cbot的Python项目详细描述
CBOT
一个中文聊天机器人
CBOT使用简介:
版本:0.1.0
####如何安装CBOT: #####PIP安装CBOT #####如果在安装python levenshtein包时出错 #####您可以下载.whl文件并安装此包:python-levenshtein ####如果您想在本地使用:
from cbot import CBot cbot = CBot('cbotName') # If you start from scratch # cbot.train() # while True: # que = input('me:') # reponse = cbot.get_response(str(que)) # print('cbot:', reponse) # If you want to train some data first # The data set must be list type. # And the next sentence is the answer to the last sentence. trainList = [ '早', '早上好', '早饭吃了么', '还没呢!,你呢?', '我也没吃', '我们一起吃早饭去吧', '好呀' ] cbot.train(trainList) while True: que = input('me:') reponse = cbot.get_response(str(que)) print('cbot:', reponse)
####如果要与Turing API一起使用:
from cbot import CBot cbot = CBot('felix') cbot.turing_key = '' # you should git an api key at http://www.tuling123.com/ while True: que = input('我:') reponse = cbot.get_response(str(que), api='turing') print('CBot:', reponse)
###现在玩得开心! ###如果你得到一个错误,你可以把错误发送到我的电子邮件。 ###这是我的电子邮件:felix2@foxmail.com