-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot_chatdata.py
36 lines (34 loc) · 1.37 KB
/
bot_chatdata.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
import re
import random
from psych_chatreflections import PsychChatReflections
from psych_chatdata import PsychoChatData
from love_chatdata import LoveChatData
from philo_chatdata import PhiloChatData
from eliza_chatdata import ElizaChatData
from fb_chatdata import FacebookChatData
class BotChatData():
def __init__(self):
self.reflections = PsychChatReflections().reflections
self.psychobabble = []
self.addChatData(FacebookChatData().psychobabble)
self.addChatData(ElizaChatData().psychobabble)
self.addChatData(PsychoChatData().psychobabble)
#self.addChatData(LoveChatData().psychobabble)
#self.addChatData(PhiloChatData().psychobabble)
def addChatData(self,chatdata):
if self.psychobabble == []:
self.psychobabble = chatdata
else:
for pattern, responses in chatdata:
isFound = False
for patt, resp in self.psychobabble:
if pattern == patt:
isFound = True
for reply in responses:
if reply not in resp:
resp.append(reply)
if isFound == False:
data =[]
data.append(pattern)
data.append(responses)
self.psychobabble.insert(-1,data)