Skip to content
Snippets Groups Projects
Commit 2f51b209 authored by Jonas Wolff's avatar Jonas Wolff
Browse files

Fixed wrong actions, corrected few typos.

parent 36ddd9b0
No related branches found
No related tags found
1 merge request!20Example
...@@ -58,8 +58,6 @@ class ActionSearchDayOfDeath(Action): ...@@ -58,8 +58,6 @@ class ActionSearchDayOfDeath(Action):
for row in spamreader: for row in spamreader:
if name_regex.match(row['name']): if name_regex.match(row['name']):
actual_day_of_death = row['day_of_death'] 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 [])] return [SlotSet('day_of_death', actual_day_of_death if actual_day_of_death is not None else [])]
...@@ -94,8 +92,6 @@ class ActionSearchPlaceOfDeath(Action): ...@@ -94,8 +92,6 @@ class ActionSearchPlaceOfDeath(Action):
for row in spamreader: for row in spamreader:
if name_regex.match(row['name']): if name_regex.match(row['name']):
actual_place_of_death = row['place_of_death'] 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 [])] return [SlotSet('place_of_death', actual_place_of_death if actual_place_of_death is not None else [])]
...@@ -123,9 +119,6 @@ class ActionSearchIsAlive(Action): ...@@ -123,9 +119,6 @@ class ActionSearchIsAlive(Action):
import csv import csv
import re import re
person = tracker.get_slot('physicist') person = tracker.get_slot('physicist')
if person == None:
dispatcher.utter_message("Person nicht gefunden")
return []
name_regex = re.compile(person, re.IGNORECASE) name_regex = re.compile(person, re.IGNORECASE)
actual_is_alive = None actual_is_alive = None
with open('data.tsv') as csvfile: with open('data.tsv') as csvfile:
...@@ -133,8 +126,6 @@ class ActionSearchIsAlive(Action): ...@@ -133,8 +126,6 @@ class ActionSearchIsAlive(Action):
for row in spamreader: for row in spamreader:
if name_regex.match(row['name']): if name_regex.match(row['name']):
actual_is_alive = row['is_alive'] 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 [])] return [SlotSet('is_alive', actual_is_alive if actual_is_alive is not None else [])]
...@@ -169,8 +160,6 @@ class ActionSearchNumSpouses(Action): ...@@ -169,8 +160,6 @@ class ActionSearchNumSpouses(Action):
for row in spamreader: for row in spamreader:
if name_regex.match(row['name']): if name_regex.match(row['name']):
actual_num_spouses = row['num_spouses'] 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 [])] return [SlotSet('num_spouses', actual_num_spouses if actual_num_spouses is not None else [])]
...@@ -205,8 +194,6 @@ class ActionSearchPrimaryEducation(Action): ...@@ -205,8 +194,6 @@ class ActionSearchPrimaryEducation(Action):
for row in spamreader: for row in spamreader:
if name_regex.match(row['name']): if name_regex.match(row['name']):
actual_primary_education = row['primary_education'] 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 [])] return [SlotSet('primary_education', actual_primary_education if actual_primary_education is not None else [])]
...@@ -241,22 +228,20 @@ class ActionSearchUniversity(Action): ...@@ -241,22 +228,20 @@ class ActionSearchUniversity(Action):
for row in spamreader: for row in spamreader:
if name_regex.match(row['name']): if name_regex.match(row['name']):
actual_university = row['university'] actual_university = row['university']
if actual_university is None:
return[SlotSet('university', [])]
return [SlotSet('university', actual_university if actual_university is not None else [])] return [SlotSet('university', actual_university if actual_university is not None else [])]
class ActionUtterAreaOfResearch(Action): class ActionUtterUniversity(Action):
def name(self): def name(self):
return 'action_utter_area_of_research' return 'action_utter_university'
def run(self, dispatcher, tracker, domain): def run(self, dispatcher, tracker, domain):
person = tracker.get_slot('physicist') person = tracker.get_slot('physicist')
area_of_research = tracker.get_slot('area_of_research') university = tracker.get_slot('university')
if area_of_research == None: if university == None:
dispatcher.utter_message("Error: Area of Research of " + person + "not known.") dispatcher.utter_message("Error: University of " + person + "not known.")
else: else:
dispatcher.utter_message("The Area of research of " + person + " is " + area_of_research + ".") dispatcher.utter_message("The University of " + person + " is " + university + ".")
return [] return []
# #
...@@ -277,8 +262,6 @@ class ActionSearchWorkplace(Action): ...@@ -277,8 +262,6 @@ class ActionSearchWorkplace(Action):
for row in spamreader: for row in spamreader:
if name_regex.match(row['name']): if name_regex.match(row['name']):
actual_workplace = row['workplace'] actual_workplace = row['workplace']
if actual_workplace is None:
return[SlotSet('workplace', [])]
return [SlotSet('workplace', actual_workplace if actual_workplace is not None else [])] return [SlotSet('workplace', actual_workplace if actual_workplace is not None else [])]
...@@ -313,8 +296,6 @@ class ActionSearchAwards(Action): ...@@ -313,8 +296,6 @@ class ActionSearchAwards(Action):
for row in spamreader: for row in spamreader:
if name_regex.match(row['name']): if name_regex.match(row['name']):
actual_awards = row['awards'] actual_awards = row['awards']
if actual_awards is None:
return[SlotSet('awards', [])]
return [SlotSet('awards', actual_awards if actual_awards is not None else [])] return [SlotSet('awards', actual_awards if actual_awards is not None else [])]
...@@ -328,5 +309,5 @@ class ActionUtterAwards(Action): ...@@ -328,5 +309,5 @@ class ActionUtterAwards(Action):
if awards == None: if awards == None:
dispatcher.utter_message("Error: Awards of " + person + "not known.") dispatcher.utter_message("Error: Awards of " + person + "not known.")
else: else:
dispatcher.utter_message("The Awards of " + person + " is " + awards + ".") dispatcher.utter_message("The Awards of " + person + " are " + awards + ".")
return [] return []
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment