Exemple #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
Exemple #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
Exemple #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
Exemple #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