-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchatbot_6.py
32 lines (28 loc) · 951 Bytes
/
chatbot_6.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
from chatterbot import ChatBot
import logging
from chatterbot.trainers import ChatterBotCorpusTrainer
# Uncomment the following line to enable verbose logging
# logging.basicConfig(level=logging.INFO)
# Create a new instance of a ChatBot
bot = ChatBot("Terminal",
logic_adapters=[
"chatterbot.logic.BestMatch"
],
input_adapter="chatterbot.input.TerminalAdapter",
output_adapter="chatterbot.output.TerminalAdapter",
database="./database_6.db"
)
bot.set_trainer(ChatterBotCorpusTrainer)
bot.train(
"./data/data_corpus.txt",
)
print("Type something to begin...")
# The following loop will execute each time the user enters input
while True:
try:
# We pass None to this method because the parameter
# is not used by the TerminalAdapter
bot_input = bot.get_response(None)
# Press ctrl-c or ctrl-d on the keyboard to exit
except (KeyboardInterrupt, EOFError, SystemExit):
break