ChatterBot人工智能,聊天机器人,无坑指南(安装,使用)(2.使用篇)
作者:互联网
代码:
1 from chatterbot import ChatBot 2 chatbot = ChatBot( 3 'Charlie', #机器人名字 4 trainer='chatterbot.trainers.ListTrainer' 5 ) 6 7 # 对话语料对,一问一答 8 conversation = [ 9 "Hello", 10 "Hi there!", 11 "How are you doing?", 12 "I'm doing great.", 13 "That is good to hear", 14 "Thank you.", 15 "You're welcome."] 16 chatbot.train(conversation) 17 18 response = chatbot.get_response(input("话:")) #获取回答 19 print(response)
默认使用的Levenshtein distance算法能让引擎从问答对中选出一个相近的回答
标签:conversation,人工智能,chatterbot,chatbot,ChatBot,doing,无坑,ChatterBot,response 来源: https://www.cnblogs.com/Ctrl-cCtrl-v/p/13220619.html