For example, here is a sample convo
Enter Your Name: James
Welcome to Chatbot Service! Let me know how can I help you
James: Hi!
Bot: everything’s been good with you? i haven’t been better. how about yourself?
James: I am doing well
Bot: That is good to hear
James: What are you doing today
Bot: i’m doing great. what about you? i’m absolutely lovely, thank you.
James: What is your favorite movie
Bot: that was my favorite class. you have got to be talented.
James: What class are you talking about
Bot: of course they talk to each other. what do they talk about?
James: They gossip about horrible things
Bot: i feel the same way. it smells so good after it rains. i especially love the night air when it rains.
James: quit
Bot: well, she’s quite short. how tall would you say that she is?
James: bye
Bot: Bye
Here is the code I have
import numpy as np # linear algebra|
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
from chatterbot.trainers import ChatterBotCorpusTrainer
import os
import collections.abc
collections.Hashable = collections.abc.Hashable
bot = ChatBot('Buddy',
logic_adapters=[{
'import_path': 'chatterbot.logic.BestMatch',
'default_response': 'I am sorry, but I do not understand.',
'maximum_similarity_threshold': 0.90
}],
read_only = True,
preprocessors=['chatterbot.preprocessors.clean_whitespace',
'chatterbot.preprocessors.unescape_html',
'chatterbot.preprocessors.convert_to_ascii']
)
directory = 'kaggle'
for filename in os.listdir(directory):
if filename.endswith(".txt"): # only pick txt file for training
print('\n Chatbot training with '+os.path.join(directory, filename)+' file')
training_data = open(os.path.join(directory, filename), 'r', encoding='utf-8').read().splitlines()
trainer = ListTrainer(bot) # bot training
trainer.train(training_data)
else:
continue
decision = input('Train chatbot with English corpus data? (Y/N): ')
if decision == 'Y':
print('\n Chatbot training with English corpus data')
trainer_corpus = ChatterBotCorpusTrainer(bot)
trainer_corpus.train('chatterbot.corpus.english')
name = input('Enter Your Name: ')
print ('Welcome to Chatbot Service! Let me know how can I help you')
while True:
request = input(name+': ')
if request=="Bye" or request=='bye':
print('Bot: Bye')
break
else:
response=bot.get_response(request)
print('Bot: ', response)
r/learnmachinelearning
r/mlquestions
r/localllama