Beispiel #1
0
 def run(self, conversation: Conversation):
     if self.entity_id not in self.dialog.entity_dict:
         raise Exception()
     entity_grammar = self.dialog.entity_dict[self.entity_id]
     search_term = conversation.user_input.strip().lower()
     if search_term in entity_grammar:
         conversation.current_input_context = {
             self.dynamic_field_assignment: entity_grammar[search_term].value
         }
         return True
     else:
         return False
Beispiel #2
0
 def run(self, conversation: Conversation):
     if self.entity_id not in self.dialog.entity_dict:
         raise Exception()
     entity_grammar = self.dialog.entity_dict[self.entity_id]
     search_term = conversation.user_input.strip().lower()
     if search_term in entity_grammar:
         conversation.current_input_context = {
             self.dynamic_field_assignment:
             entity_grammar[search_term].value
         }
         return True
     else:
         return False
Beispiel #3
0
 def run(self, conversation: Conversation):
     matches = re.findall(self.pattern, conversation.user_input, self.flags)
     if not any(matches):
         return False
     elif any(matches) and self.dynamic_field_assignments is None:
         return True
     elif len(matches) == len(self.dynamic_field_assignments):
         assignments = zip(self.dynamic_field_assignments, matches)
         conversation.current_input_context = {}
         for key, value in assignments:
             conversation.current_input_context[key] = value
         return True
     else:
         return False
Beispiel #4
0
 def run(self, conversation: Conversation):
     matches = re.findall(self.pattern, conversation.user_input, self.flags)
     if not any(matches):
         return False
     elif any(matches) and self.dynamic_field_assignments is None:
         return True
     elif len(matches) == len(self.dynamic_field_assignments):
         assignments = zip(self.dynamic_field_assignments, matches)
         conversation.current_input_context = {}
         for key, value in assignments:
             conversation.current_input_context[key] = value
         return True
     else:
         return False