Python大作业——聊天机器人

训练机器人代码
 1 from chatterbot import ChatBot
 2 from chatterbot.trainers import ListTrainer
 3 
 4 
 5 bot = ChatBot("chatbot",read_only=False,logic_adapters=["chatterbot.logic.BestMatch"])
 6 
 7 list_to_train = {
 8     "hi",
 9     "hi there",
10     "what's your name?",
11     "I'm a chatbot",
12     "how old are you?",
13     "I'm ageless!"
14 }
15 
16 list_trainer = ListTrainer(bot)
17 list_trainer.train(list_to_train)

 

posted @ 2024-05-29 21:46  新晋软工小白  阅读(85)  评论(0)    收藏  举报