forked from huzaifsayed/coronabot-chatterbot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbot.py
33 lines (28 loc) · 1.11 KB
/
bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
from chatterbot.trainers import ChatterBotCorpusTrainer
# chatbot instance
chatbot = ChatBot(
'OfficeBot',
storage_adapter='chatterbot.storage.SQLStorageAdapter',
logic_adapters=[
'chatterbot.logic.MathematicalEvaluation',
'chatterbot.logic.TimeLogicAdapter',
'chatterbot.logic.BestMatch',
{
'import_path': 'chatterbot.logic.BestMatch',
'default_response': 'I am sorry, but I do not understand. I am still learning.',
'maximum_similarity_threshold': 0.90
}
],
database_uri='sqlite:///database.sqlite3'
)
# training with Qs and As from txt files
training_data_training = open('training_data/training.txt').read().splitlines()
training_data_personal = open('training_data/personal.txt').read().splitlines()
training_data = training_data_training + training_data_personal
trainer = ListTrainer(chatbot)
trainer.train(training_data)
# train with english Corpus data
trainer_corpus = ChatterBotCorpusTrainer(chatbot)
trainer_corpus.train('chatterbot.corpus.english')