def _references_resolution_replace_current_object_with_ua_exception( self, sentence, uae_object, uae_object_with_more_info, uae_object_list): """This attempts to replace a nominal group that has failled from identifying the anaphoric word with one that holds more information. """ current_object = None if uae_object_with_more_info[1]: current_object = uae_object_with_more_info[0] else: sf = SentenceFactory() raise UnidentifiedAnaphoraError({ 'object': uae_object, 'object_to_confirm': uae_object_with_more_info[0], 'object_with_more_info': None, 'objects_list': uae_object_list, 'sentence': sentence, 'question': sf.create_do_you_mean_reference(uae_object_with_more_info[0]) }) return current_object
def _references_resolution_with_anaphora_matcher(self, nominal_group, matcher, current_speaker, current_object): """ This attempts to match the nominal group containing anaphoric words with an object identifed from the dialog history. If several candidates are found, a confirmation is asked to user. """ if current_object: self._current_object = None return current_object # Trying to match anaphora if not self.sentences_store: raise DialogError("Empty Dialog history") sf = SentenceFactory() #object = [ng, [List]] # Where ng is the first nominal group to match with the anaphoric word # and List contains nominal group that are to be explored if ng is not confirmed from the user object = matcher.match_first_object(get_last(self.sentences_store, 10), nominal_group) if not object: raise DialogError("No anaphora matches in dialog history") # Case there exist only one nominal group identified from anaphora matching if len(object[1]) == 1: nominal_group = object[0] logger.debug("Found anaphoric match " + str(nominal_group)) # Else, ask for confirmation to the user else: raise UnidentifiedAnaphoraError({ 'object': nominal_group, 'object_to_confirm': object[0], 'object_with_more_info': None, 'objects_list': object[1], 'sentence': self._current_sentence, 'question': sf.create_do_you_mean_reference(object[0]) }) ResourcePool().mark_active(nominal_group.id) return nominal_group
def _references_resolution_replace_current_object_with_ua_exception(self, sentence, uae_object, uae_object_with_more_info, uae_object_list): """This attempts to replace a nominal group that has failled from identifying the anaphoric word with one that holds more information. """ current_object = None if uae_object_with_more_info[1]: current_object = uae_object_with_more_info[0] else: sf = SentenceFactory() raise UnidentifiedAnaphoraError({'object': uae_object, 'object_to_confirm': uae_object_with_more_info[0], 'object_with_more_info': None, 'objects_list': uae_object_list, 'sentence': sentence, 'question': sf.create_do_you_mean_reference(uae_object_with_more_info[0])}) return current_object
def _references_resolution_with_anaphora_matcher(self, nominal_group, matcher, current_speaker, current_object): """ This attempts to match the nominal group containing anaphoric words with an object identifed from the dialog history. If several candidates are found, a confirmation is asked to user. """ if current_object: self._current_object = None return current_object # Trying to match anaphora if not self.sentences_store: raise DialogError("Empty Dialog history") sf = SentenceFactory() #object = [ng, [List]] # Where ng is the first nominal group to match with the anaphoric word # and List contains nominal group that are to be explored if ng is not confirmed from the user object = matcher.match_first_object(get_last(self.sentences_store, 10), nominal_group) if not object: raise DialogError("No anaphora matches in dialog history") # Case there exist only one nominal group identified from anaphora matching if len(object[1]) == 1: nominal_group = object[0] logger.debug("Found anaphoric match " + str(nominal_group)) # Else, ask for confirmation to the user else: raise UnidentifiedAnaphoraError({'object': nominal_group, 'object_to_confirm': object[0], 'object_with_more_info': None, 'objects_list': object[1], 'sentence': self._current_sentence, 'question': sf.create_do_you_mean_reference(object[0])}) ResourcePool().mark_active(nominal_group.id) return nominal_group