예제 #1
0
    def post_init_hook(self):
        """
        The post-initialize hook  for attaching global receptors.

        Here we connect the interaction's Global Receptors with InformationController
        :return:
        """
        ############### Prepare RECEPTOR #################################################
        # this Interaction may be activated by Receptor (actually it is binary intent classifier here)
        self.global_trigger_receptor = PhrasesMatcher(
            phrases=["ПОЗНАКОМИМСЯ", "ЗНАКОМСТВО", "/start"],
            daemon_if_matched=self.start)
        # connect receptor:
        self.ic.user_message_signal.connect(self.global_trigger_receptor,
                                            weak=False)
        slots_factory = SlotsFactory()
        self.username_slot = slots_factory.produce_free_text_slot(
            'username_slot', "Как тебя зовут?")
        self.ic.sm.register_slot(self.username_slot)

        self.interests_slot = slots_factory.produce_categorical_slot(
            name='interests_slot',
            questioner="Какие имеешь увлечения?",
            categories_domain_specification={
                "MOVIES": ["Кино", "Фильм"],
                "MUSIC": ["Музык", "Гитар"],
                "SPORT": ["Спорт", "Кёрлинг", "Шахмат"],
                "BOOKS": ["Книги", "Чита"]
            })
        self.ic.sm.register_slot(self.interests_slot)

        ########## Concrete FormFillingProcess Declaration/Initialization/ Registering:
        name = "PrivateInfoSlottyForm2"
        slots = [self.username_slot, self.interests_slot]
        # slots = [self.interests_slot, username_slot]
        self.sfi = SlottyFormInteraction(name, slots)
        self.ic.im.register_interaction(self.sfi)

        #############################################################################################
        # TODO fix hardcode shit
        # initialize interaction:
        self.sfi.ic = self.ic
        self.sfi.EXIT_GATES_SIGNALS = {}

        if not hasattr(self.sfi, 'EXIT_GATES_NAMES_LIST'):
            # TODO fix to support inheritance of ExitGates!
            # then import default Gates :
            self.sfi.EXIT_GATES_NAMES_LIST = self.sfi.base_EXIT_GATES_NAMES_LIST

        # now init signal objects for each exit gate:
        for each_exit_gate_name in self.sfi.EXIT_GATES_NAMES_LIST:
            # create a signal object for each exit gate
            self.sfi.EXIT_GATES_SIGNALS[
                each_exit_gate_name] = django.dispatch.dispatcher.Signal(
                    providing_args=["userdialog"])

        # self.sfi._anti_garbage_collector_callbacks_list = []
        # END ExitGate Signals Initialization

        self.sfi.post_init_hook()
예제 #2
0
    def post_init_hook(self):
        """The post-initialize hook for attaching global receptors.

        Here we connect the interaction's Global Receptors with InformationController

        Returns:

        """
        # this Interaction may be activated by Receptor (actually it is binary intent classifier here)
        self.global_trigger_receptor = PhrasesMatcher(phrases=["MAKE ALARM",
                                                               "SET REMINDER",
                                                               "SET ALARM",
                                                               "НАПОМИНАЛКА",
                                                               "НАПОМИНАЛКУ",
                                                               "УСТАНОВИ БУДИЛЬНИК",
                                                               "/SetAlarm"
                                                               ],
                                                      daemon_if_matched=self.start)

        # TODO add support of triggers:
        # установи будильник на 16 20
        # включи будильник в 4 35
        # напомни мне сварить кашу через 2 часа 15 минут
        # напомни написать письмо научному руководителю завтра
        # напомни написать письмо научному руководителю в обед
        # установи напоминалку сходить в бассейн в субботу вечером
        # установи напоминалку сходить в бассейн на 4 апреля

        self.ic.user_message_signal.connect(self.global_trigger_receptor, weak=False)

        self._prepare_slots()
예제 #3
0
def phrase_matcher_hand_test():
    hi = PhrasesMatcher(phrases=["Hello", "Kek", "Hi"])
    bye = PhrasesMatcher(phrases=["Bye", "Lol", "Exit"])
    disjoint_matchers = [hi, bye]
    pgmc = PhraseGroupsMatcherController(disjoint_matchers)

    # ivanov_ivan_receptor = TrainigPhrasesMatcher(training_phrases=["Ivanov Ivan"])
    print("Kek")
    print(pgmc("Kek"))
    print("Bye")
    print(pgmc("Bye"))
    print("jasdhjsdh")
    print(pgmc("jasdhjsdh"))

    print("Hi Kek, Lol, ki")
    print(pgmc("Hi Kek, Lol, ki"))
    print("***********************")
예제 #4
0
    def post_init_hook(self):
        """
        The post-initialize hook  for attaching global receptors.

        Here we connect the interaction's Global Receptors with InformationController
        :return:
        """
        # this Interaction may be activated by Receptor (actually it is binary intent classifier here)
        self.global_trigger_receptor = PhrasesMatcher(
            phrases=["ОПЕРАТОР", "Переключите меня на оператора"],
            daemon_if_matched=self.start)
        self.ic.user_message_signal.connect(self.global_trigger_receptor,
                                            weak=False)
예제 #5
0
    def connect_to_dataflow(self, udc):
        """
        The post-initialize hook  for attaching global receptors.

        Here we connect the interaction's Global Receptors with InformationController
        :return:
        """
        # this Interaction may be activated by Receptor (actually it is binary intent classifier here)
        self.global_trigger_receptor = PhrasesMatcher(
            phrases=["slots", "слоты", "Memory"], daemon_if_matched=self.start)
        # connect receptor:
        udc.user_message_signal.connect(self.global_trigger_receptor,
                                        weak=False)
예제 #6
0
    def post_init_hook(self):

        # self.exit_gate_signal = django.dispatch.Signal(providing_args=["userdialog"])

        # ic.active_receptors.append(self.global_trigger_receptor)
        self.scenario = SendTextOperation(text=self.out_text)
        # this Interaction may be activated by Receptor
        # TODO templatize
        self.global_trigger_receptor = PhrasesMatcher(
            phrases=[
                "Привет", "Здравствуйте", "Hello", "Kek", "Hi", "Приветик",
                "БАНК", "КОНСУЛЬТАЦИЯ"
            ],
            daemon_if_matched=self.start)

        # here we connect the interaction's Global Receptors with InformationController's UserMessageEvent
        # (IC helps to adapt user-agnostic Interaction specification for particular User Case)
        self.ic.user_message_signal.connect(self.global_trigger_receptor,
                                            weak=False)
    def post_init_hook(self):
        """
        The post-initialize hook  for attaching global receptors.

        Here we connect the interaction's Global Receptors with InformationController
        :return:
        """
        ############### Prepare RECEPTOR #################################################
        # this Interaction may be activated by Receptor (actually it is binary intent classifier here)
        self.global_trigger_receptor = PhrasesMatcher(
            phrases=[
                "What is the weather in *", "Gimme weather", "Will it rain?",
                "Give me forecast for tomorrow", "ПОГОДА", "КАКАЯ ПОГОДА",
                "\Weather"
            ],
            daemon_if_matched=self.start)
        # connect receptor:
        self.ic.user_message_signal.connect(self.global_trigger_receptor,
                                            weak=False)

        self._prepare_slots()