-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
54 lines (46 loc) · 1.69 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# -*- coding: utf-8 -*-
from chatterbot import ChatBot
# Uncomment the following lines to enable verbose logging
# import logging
# logging.basicConfig(level=logging.INFO)
# Create a new instance of a ChatBot
is_set_to_read_only = True
bot = ChatBot(
"Terminal",
storage_adapter="chatterbot.storage.SQLStorageAdapter",
# trainer='chatterbot.trainers.ChatterBotCorpusTrainer',
# input_adapter="chatterbot.input.TerminalAdapter",
# output_adapter="chatterbot.output.TerminalAdapter",
logic_adapters=[
"chatterbot.logic.MathematicalEvaluation",
"chatterbot.logic.BestMatch",
{
'import_path': 'chatterbot.logic.LowConfidenceAdapter',
'threshold': 0.65,
'default_response': 'I am sorry, but I do not understand this yet. Please let me train some more'
},
{
'import_path': 'chatterbot.logic.SpecificResponseAdapter',
'input_text': 'Help me!',
'output_text': 'Ask the creater! The one true GOD!'
}
],
database="./db.sqlite3",
preprocessors=[
'chatterbot.preprocessors.convert_to_ascii'
],
read_only = is_set_to_read_only,
)
#bot.train('chatterbot.corpus.english')
if __name__ == '__main__':
# The following loop will execute each time the user enters input
print("Type something to begin...")
while True:
try:
# We pass None to this method because the parameter
# is not used by the TerminalAdapter
# bot_input = bot.get_response()
print(bot.get_response(input()))
# Press ctrl-c or ctrl-d on the keyboard to exit
except (KeyboardInterrupt, EOFError, SystemExit):
break