|
a |
|
b/train.py |
|
|
1 |
from chatterbot import ChatBot |
|
|
2 |
from chatterbot.trainers import ListTrainer |
|
|
3 |
import os |
|
|
4 |
|
|
|
5 |
try: |
|
|
6 |
os.remove("db.sqlite3") |
|
|
7 |
print("Old database removed. Training new database") |
|
|
8 |
except: |
|
|
9 |
print('No database found. Creating new database.') |
|
|
10 |
|
|
|
11 |
english_bot = ChatBot('Bot') |
|
|
12 |
english_bot.set_trainer(ListTrainer) |
|
|
13 |
for file in os.listdir('data'): |
|
|
14 |
print('Training using '+file) |
|
|
15 |
convData = open('data/' + file).readlines() |
|
|
16 |
english_bot.train(convData) |
|
|
17 |
print("Training completed for "+file) |
|
|
18 |
|
|
|
19 |
|