from chatterbot.trainers import ListTrainer # Create a new instance of a ChatBot popat = ChatBot("Terminal", storage_adapter="chatterbot.storage.sql_storage.SQLStorageAdapter", logic_adapters=[ "chatterbot.logic.mathematical_evaluation.MathematicalEvaluation", "chatterbot.logic.time_adapter.TimeLogicAdapter", "chatterbot.logic.best_match.BestMatch" ], input_adapter="chatterbot.input.terminal.TerminalAdapter", output_adapter="chatterbot.output.terminal.TerminalAdapter", database="../database.db" ) popat.set_trainer(ListTrainer) popat.train([ "hi", "hello", "how are you", "why are you interested", "that is good to hear", "thank you", "you are welcome", "sorry", "its okay", "what is your name", "my name is popat", ]) print("Type something to begin...")
from chatterbot.chatterbot import ChatBot # import the chatbot from pep8 import readlines from chatterbot.trainers import ListTrainer # method to train the chatbot bot = ChatBot('Test') # create the chatbot conv = open('chat.txt', 'r').readlines() bot.set_trainer(ListTrainer) # set the trainers bot.train(conv) # train the bot while True: request = input('You: ') response = bot.get_response(request) print('Bot: ', response)