"...cwa-app-android.git" did not exist on "100d5aa9a7d45cc14b4359f61091d37c336f7a68"
Newer
Older
from rasa_core_sdk import Action
from rasa_core_sdk.events import SlotSet
class ActionSearchBirthplace(Action):
def name(self):
return 'action_search_birthplace'
def run(self, dispatcher, tracker, domain):
person = tracker.get_slot('physicist')
dispatcher.utter_message("Person found:" + person)
#import csv
#import re
#person = tracker.get_slot('physicist')
#name_regex = re.compile(person, re.IGNORECASE)
#actual_birthplace = None
#with open('data.tsv') as csvfile:
# spamreader = csv.DictReader(csvfile, delimiter='\t')
# for row in spamreader:
# if name_regex.match(row['name']):
# actual_birthplace = row['birthplace']
#if actual_birthplace is None:
return[SlotSet('birthplace', [])]
#return [SlotSet('birthplace', actual_birthplace if actual_birthplace is not None else [])]
class ActionUtterBirthplace(Action):
return 'action_utter_birthplace'
#person = tracker.get_slot('physicist')
#birthplace = tracker.get_slot('birthplace')
#if birthplace == None:
# dispatcher.utter_message("Error: Birthplace of " + person + " not
# known.")
#else:
# dispatcher.utter_message("The birthplace of " + person + " is " +
# birthplace + ".")
#
# Day of death
#
class ActionSearchDayOfDeath(Action):
def name(self):
return 'action_search_day_of_death'
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
def run(self, dispatcher, tracker, domain):
import csv
import re
person = tracker.get_slot('physicist')
name_regex = re.compile(person, re.IGNORECASE)
actual_day_of_death = None
with open('data.tsv') as csvfile:
spamreader = csv.DictReader(csvfile, delimiter='\t')
for row in spamreader:
if name_regex.match(row['name']):
actual_day_of_death = row['day_of_death']
if actual_day_of_death is None:
return[SlotSet('day_of_death', [])]
return [SlotSet('day_of_death', actual_day_of_death if actual_day_of_death is not None else [])]
class ActionUtterDayOfDeath(Action):
def name(self):
return 'action_utter_day_of_death'
def run(self, dispatcher, tracker, domain):
person = tracker.get_slot('physicist')
day_of_death = tracker.get_slot('day_of_death')
if day_of_death == None:
dispatcher.utter_message("Error: day of death of " + person + "not known.")
else:
dispatcher.utter_message("The day of death of " + person + " is " + day_of_death + ".")
return []
#
# Place of death
#
class ActionSearchPlaceOfDeath(Action):
def name(self):
return 'action_search_place_of_death'
def run(self, dispatcher, tracker, domain):
import csv
import re
person = tracker.get_slot('physicist')
name_regex = re.compile(person, re.IGNORECASE)
actual_place_of_death = None
with open('data.tsv') as csvfile:
spamreader = csv.DictReader(csvfile, delimiter='\t')
for row in spamreader:
if name_regex.match(row['name']):
actual_place_of_death = row['place_of_death']
if actual_place_of_death is None:
return[SlotSet('place_of_death', [])]
return [SlotSet('place_of_death', actual_place_of_death if actual_place_of_death is not None else [])]
class ActionUtterPlaceOfDeath(Action):
def name(self):
return 'action_utter_place_of_death'
def run(self, dispatcher, tracker, domain):
person = tracker.get_slot('physicist')
place_of_death = tracker.get_slot('place_of_death')
if place_of_death == None:
dispatcher.utter_message("Error: Place of death of " + person + "not known.")
else:
dispatcher.utter_message("The place of death of " + person + " is " + place_of_death + ".")
return []
#
# Is alive
#
class ActionSearchIsAlive(Action):
def name(self):
return 'action_search_is_alive'
def run(self, dispatcher, tracker, domain):
import csv
import re
person = tracker.get_slot('physicist')
if person == None:
dispatcher.utter_message("Person nicht gefunden")
return []
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
name_regex = re.compile(person, re.IGNORECASE)
actual_is_alive = None
with open('data.tsv') as csvfile:
spamreader = csv.DictReader(csvfile, delimiter='\t')
for row in spamreader:
if name_regex.match(row['name']):
actual_is_alive = row['is_alive']
if actual_is_alive is None:
return[SlotSet('is_alive', [])]
return [SlotSet('is_alive', actual_is_alive if actual_is_alive is not None else [])]
class ActionUtterPlaceOfDeath(Action):
def name(self):
return 'action_utter_is_alive'
def run(self, dispatcher, tracker, domain):
person = tracker.get_slot('physicist')
is_alive = tracker.get_slot('is_alive')
if is_alive == None:
dispatcher.utter_message("Error: Life status of " + person + "not known.")
else:
dispatcher.utter_message("The Life status of " + person + " is " + is_alive + ".")
return []
#
# num spouses
#
class ActionSearchNumSpouses(Action):
def name(self):
return 'action_search_num_spouses'
def run(self, dispatcher, tracker, domain):
import csv
import re
person = tracker.get_slot('physicist')
name_regex = re.compile(person, re.IGNORECASE)
actual_num_spouses = None
with open('data.tsv') as csvfile:
spamreader = csv.DictReader(csvfile, delimiter='\t')
for row in spamreader:
if name_regex.match(row['name']):
actual_num_spouses = row['num_spouses']
if actual_num_spouses is None:
return[SlotSet('num_spouses', [])]
return [SlotSet('num_spouses', actual_num_spouses if actual_num_spouses is not None else [])]
class ActionUtterNumSpouses(Action):
def name(self):
return 'action_utter_num_spouses'
def run(self, dispatcher, tracker, domain):
person = tracker.get_slot('physicist')
num_spouses = tracker.get_slot('num_spouses')
if num_spouses == None:
dispatcher.utter_message("Error: Number of Spouses of " + person + "not known.")
else:
dispatcher.utter_message("The Number of spouses of " + person + " is " + num_spouses + ".")
return []
#
# Primary Education
#
class ActionSearchPrimaryEducation(Action):
def name(self):
return 'action_search_primary_education'
def run(self, dispatcher, tracker, domain):
import csv
import re
person = tracker.get_slot('physicist')
name_regex = re.compile(person, re.IGNORECASE)
actual_primary_education = None
with open('data.tsv') as csvfile:
spamreader = csv.DictReader(csvfile, delimiter='\t')
for row in spamreader:
if name_regex.match(row['name']):
actual_primary_education = row['primary_education']
if actual_primary_education is None:
return[SlotSet('primary_education', [])]
return [SlotSet('primary_education', actual_primary_education if actual_primary_education is not None else [])]
class ActionUtterPrimaryEducation(Action):
def name(self):
return 'action_utter_primary_education'
def run(self, dispatcher, tracker, domain):
person = tracker.get_slot('physicist')
primary_education = tracker.get_slot('primary_education')
if primary_education == None:
dispatcher.utter_message("Error: Primary education of " + person + "not known.")
else:
dispatcher.utter_message("The primary education of " + person + " is " + primary_education + ".")
return []
#
# University
#
class ActionSearchUniversity(Action):
def name(self):
return 'action_search_university'
def run(self, dispatcher, tracker, domain):
import csv
import re
person = tracker.get_slot('physicist')
name_regex = re.compile(person, re.IGNORECASE)
actual_university = None
with open('data.tsv') as csvfile:
spamreader = csv.DictReader(csvfile, delimiter='\t')
for row in spamreader:
if name_regex.match(row['name']):
actual_university = row['university']
if actual_university is None:
return[SlotSet('university', [])]
return [SlotSet('university', actual_university if actual_universtiy is not None else [])]
class ActionUtterAreaOfResearch(Action):
def name(self):
return 'action_utter_area_of_research'
def run(self, dispatcher, tracker, domain):
person = tracker.get_slot('physicist')
area_of_research = tracker.get_slot('area_of_research')
if area_of_research == None:
dispatcher.utter_message("Error: Area of Research of " + person + "not known.")
else:
dispatcher.utter_message("The Area of research of " + person + " is " + area_of_research + ".")
return []
#
# Workplace
#
class ActionSearchWorkplace(Action):
def name(self):
return 'action_search_workplace'
def run(self, dispatcher, tracker, domain):
import csv
import re
person = tracker.get_slot('physicist')
name_regex = re.compile(person, re.IGNORECASE)
actual_workplace = None
with open('data.tsv') as csvfile:
spamreader = csv.DictReader(csvfile, delimiter='\t')
for row in spamreader:
if name_regex.match(row['name']):
actual_workplace = row['workplace']
if actual_workplace is None:
return[SlotSet('workplace', [])]
return [SlotSet('workplace', actual_workplace if actual_workplace is not None else [])]
class ActionUtterWorkplace(Action):
def name(self):
return 'action_utter_workplace'
def run(self, dispatcher, tracker, domain):
person = tracker.get_slot('physicist')
workplace = tracker.get_slot('workplace')
if workplace == None:
dispatcher.utter_message("Error: Workplace of " + person + "not known.")
else:
dispatcher.utter_message("The Workplace of " + person + " is " + workplace + ".")
return []
#
# Awards
#
class ActionSearchAwards(Action):
def name(self):
return 'action_search_awards'
def run(self, dispatcher, tracker, domain):
import csv
import re
person = tracker.get_slot('physicist')
name_regex = re.compile(person, re.IGNORECASE)
actual_awards = None
with open('data.tsv') as csvfile:
spamreader = csv.DictReader(csvfile, delimiter='\t')
for row in spamreader:
if name_regex.match(row['name']):
actual_awards = row['awards']
if actual_awards is None:
return[SlotSet('awards', [])]
return [SlotSet('awards', actual_awards if actual_awards is not None else [])]
class ActionUtterAwards(Action):
def name(self):
return 'action_utter_awards'
def run(self, dispatcher, tracker, domain):
person = tracker.get_slot('physicist')
awards = tracker.get_slot('awards')
if awards == None:
dispatcher.utter_message("Error: Awards of " + person + "not known.")
else:
dispatcher.utter_message("The Awards of " + person + " is " + awards + ".")
return []