-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrain-bot.py
More file actions
59 lines (43 loc) · 1.7 KB
/
train-bot.py
File metadata and controls
59 lines (43 loc) · 1.7 KB
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
54
55
56
57
58
from chatterbot import ChatBot,response_selection
from chatterbot.trainers import ListTrainer,ChatterBotCorpusTrainer
import logging,datetime
from chatterbot.comparisons import levenshtein_distance
from chatterbot.comparisons import JaccardSimilarity
from chatterbot.comparisons import sentiment_comparison
from chatterbot.logic import LogicAdapter
from chatterbot.conversation import Statement
import logging
import DepositWithdrawAdapter
import RatcliffObershelp as ratcliffobershelp
logging.basicConfig(filename='sora_bot.log',level=logging.INFO)
d_response=["i am in beta version, i don't know a lot.",
"Maybe you can ask something else.",
"i am sorry but i didn't really get your point."]
chat_bot = ChatBot(
'Angelium',
read_only=True,
preprocessors=[
'chatterbot.preprocessors.clean_whitespace',
'chatterbot.preprocessors.convert_to_ascii',
'chatterbot.preprocessors.unescape_html'
],
logic_adapters=[
{
'import_path':'DepositWithdrawAdapter.DepositWithdrawAdapter',},
{
'import_path' : 'chatterbot.logic.BestMatch',
'statement_comparison_function' : ratcliffobershelp.Ratcliff_Obershelp,
"response_selection_method": response_selection.get_random_response,
"default_response":d_response,
"maximum_similarity_threshold":0.80
},
]
)
def train_data():
trainer = ChatterBotCorpusTrainer(chat_bot)
#trainer=ListTrainer(chat_bot)
trainer.train("./Data_1.4.yml")
print("training completed, use bot.py to talk to bot.")
def exporting_data():
trainer.export_for_training('./{}export.json'.format(datetime.datetime.now()))
train_data()