-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchat.py
More file actions
41 lines (33 loc) · 1.15 KB
/
Copy pathchat.py
File metadata and controls
41 lines (33 loc) · 1.15 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
from chatterbot import ChatBot
from settings import TWITTER
import logging
'''
This example demonstrates how you can train your chat bot
using data from Twitter.
To use this example, create a new file called settings.py.
In settings.py define the following:
TWITTER = {
"CONSUMER_KEY": "my-twitter-consumer-key",
"CONSUMER_SECRET": "my-twitter-consumer-secret",
"ACCESS_TOKEN": "my-access-token",
"ACCESS_TOKEN_SECRET": "my-access-token-secret"
}
'''
# Comment out the following line to disable verbose logging
logging.basicConfig(level=logging.INFO)
chatbot = ChatBot(
"TwitterBot",
logic_adapters=[
"chatterbot.logic.BestMatch"
],
input_adapter="chatterbot.input.TerminalAdapter",
output_adapter="chatterbot.output.TerminalAdapter",
database="./twitter-database.db",
twitter_consumer_key=TWITTER["CONSUMER_KEY"],
twitter_consumer_secret=TWITTER["CONSUMER_SECRET"],
twitter_access_token_key=TWITTER["ACCESS_TOKEN"],
twitter_access_token_secret=TWITTER["ACCESS_TOKEN_SECRET"],
trainer="chatterbot.trainers.TwitterTrainer"
)
chatbot.train()
chatbot.logger.info('Trained database generated successfully!')