-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
33 lines (27 loc) · 773 Bytes
/
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
# bot.py
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
from chatterbot.trainers import ChatterBotCorpusTrainer
# from cleaner import clean_corpus
CORPUS_FILE = "chat.txt"
chatbot = ChatBot("Chatpot")
# trainer = ListTrainer(chatbot)
trainer = ChatterBotCorpusTrainer(chatbot)
trainer.train("chatterbot.corpus.english")
# cleaned_corpus = clean_corpus(CORPUS_FILE)
# trainer.train(cleaned_corpus)
# trainer.train([
# "Hi",
# "Welcome, friend 🤗",
# ])
# trainer.train([
# "Are you a plant?",
# "No, I'm the pot below the plant!",
# ])
exit_conditions = (":q", "quit", "exit")
while True:
query = input("> ")
if query in exit_conditions:
break
else:
print(f"🪴 {chatbot.get_response(query)}")