-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
100 lines (80 loc) · 2.92 KB
/
Copy pathutils.py
File metadata and controls
100 lines (80 loc) · 2.92 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
from wit import Wit
access_token = "6WI5F3AWG37B7SMUPI53VIKY4WSF3C4U"
access_token_dudley = "P2KLAZVQTTCKRFADW4WZ4JTELKT2FX4O"
access_token_petunia = "32FYMNSQS4TBBZUZHWQ3MOL7DV5OEQWM"
access_token_hagrid = "IEXS7ZQNI66SMYBCDQBNONSYZFY4CV62"
access_token_ollivander = "2C4ZEX5J3BGPW56OVCSJ52BEO3ESKV76"
client = Wit(access_token=access_token)
client_dudley = Wit(access_token=access_token_dudley)
client_petunia = Wit(access_token=access_token_petunia)
client_hagrid = Wit(access_token=access_token_hagrid)
client_ollivander = Wit(access_token=access_token_ollivander)
def wit_response(message_text):
resp = client.message(message_text)
entity = None
value = None
try:
entity = list(resp['entities'])[0]
value = resp['entities'][entity][0]['value']
except:
pass
return(entity, value)
#I Feel like this can be condensed so I don't have different one for each character
def wit_dudley_response(message_text):
resp = client_dudley.message(message_text)
print(resp)
response_wit_parsed = {}
try:
for x in resp['entities']:
for y in resp['entities'][x]:
if x in response_wit_parsed:
response_wit_parsed[x].append(y['value'])
else:
response_wit_parsed[x] = [y['value']]
except:
print('Something definitely is broken...')
pass
return response_wit_parsed
def wit_petunia_response(message_text):
resp = client_petunia.message(message_text)
response_wit_parsed = {}
try:
for x in resp['entities']:
for y in resp['entities'][x]:
if x in response_wit_parsed:
response_wit_parsed[x].append(y['value'])
else:
response_wit_parsed[x] = [y['value']]
except:
print('Something definitely is broken...')
pass
return response_wit_parsed
#print(wit_response("I want to be in Ravenclaw"))
def wit_hagrid_response(message_text):
resp = client_hagrid.message(message_text)
response_wit_parsed = {}
try:
for x in resp['entities']:
for y in resp['entities'][x]:
if x in response_wit_parsed:
response_wit_parsed[x].append(y['value'])
else:
response_wit_parsed[x] = [y['value']]
except:
print('Something definitely is broken...')
pass
return response_wit_parsed
def wit_ollivander_response(message_text):
resp = client_ollivander.message(message_text)
response_wit_parsed = {}
try:
for x in resp['entities']:
for y in resp['entities'][x]:
if x in response_wit_parsed:
response_wit_parsed[x].append(y['value'])
else:
response_wit_parsed[x] = [y['value']]
except:
print('Something definitely is broken...')
pass
return response_wit_parsed