-
Notifications
You must be signed in to change notification settings - Fork 0
/
chatterbot.py
41 lines (32 loc) · 1.05 KB
/
chatterbot.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
from __future__ import unicode_literals
from . import utils
from ear import Ear
from mouth import Mouth
class ChatterBot(object):
"""
A chat bot.
"""
def __init__(self):
self.name = 'Gakki'
self.languages = ['English']
self.conversations = []
def listen(self, input_item, session_id=None):
if not session_id:
session_id = str(self.default_session.uuid)
self.conversations.append(Ear.process_input(input_item))
def speak(self, session_id=None):
if not session_id:
session_id = str(self.default_session.uuid)
Mouth.process_input()
def think(self):
return self.trainer = training_class(self.storage, **kwargs)
@classmethod
def from_config(cls, config_file_path):
"""
Create a new ChatBot instance from a JSON config file.
"""
import json
with open(config_file_path, 'r') as config_file:
data = json.load(config_file)
name = data.pop('name')
return ChatterBot(name, **data)