Esempio n. 1
0
    def process_sentence(self, sentence, current_speaker):
        self.builder.set_current_speaker(current_speaker)

        stmts, situation_id = self.builder.process_sentence(sentence)

        if stmts:

            self.add_stmts(stmts)

            emotions.satisfied()

            if situation_id:
                # If a new situation has been created, mark it as
                # active.
                self.output_sentence.extend(self.sfactory.create_agree_reply())
                ResourcePool().mark_active(situation_id)
        else:
            logger.info("No statements produced")

        # Class grounding
        if self.builder.lear_more_concept:
            self.output_sentence.extend(
                self.sfactory.create_what_is_a_reference(
                    sentence, self.builder.lear_more_concept))

        return stmts, situation_id
Esempio n. 2
0
    def process_sentence(self, sentence, current_speaker):
        self.builder.set_current_speaker(current_speaker)

        stmts, situation_id = self.builder.process_sentence(sentence)

        if stmts:

            self.add_stmts(stmts)

            emotions.satisfied()

            if situation_id:
                # If a new situation has been created, mark it as
                # active.
                self.output_sentence.extend(self.sfactory.create_agree_reply())
                ResourcePool().mark_active(situation_id)
        else:
            logger.info("No statements produced")

        # Class grounding
        if self.builder.lear_more_concept:
            self.output_sentence.extend(
                self.sfactory.create_what_is_a_reference(sentence, self.builder.lear_more_concept))

        return stmts, situation_id
Esempio n. 3
0
    def process_question(self, sentence, current_speaker):
        self.question_handler.set_current_speaker(current_speaker)

        # 'stmts' contains a list of statement describing the current
        # 'interrogative state' of the interactor.
        answer, stmts, situation_id = self.question_handler.process_sentence(
            sentence)

        if stmts:
            self.add_stmts(stmts)
        else:
            logger.info("No statements produced")

        if answer:
            emotions.satisfied()
            logger.info(
                level_marker(level=2, color="yellow") + "Found: \n" +
                colored_print(str(answer), None, "magenta"))
        else:
            emotions.sorry()
            logger.info(
                level_marker(level=2, color="yellow") +
                "Couldn't find anything!")

        if sentence.data_type == W_QUESTION:
            self.output_sentence.extend(
                self.sfactory.create_w_question_answer(
                    sentence, answer, self.question_handler._current_speaker,
                    self.question_handler.get_query_on_field()))

        if sentence.data_type == YES_NO_QUESTION:
            self.output_sentence.extend(
                self.sfactory.create_yes_no_answer(sentence, answer))

        return stmts, situation_id
Esempio n. 4
0
    def process_question(self, sentence, current_speaker):
        self.question_handler.set_current_speaker(current_speaker)

        # 'stmts' contains a list of statement describing the current 
        # 'interrogative state' of the interactor.
        answer, stmts, situation_id = self.question_handler.process_sentence(sentence)

        if stmts:
            self.add_stmts(stmts)
        else:
            logger.info("No statements produced")

        if answer:
            emotions.satisfied()
            logger.info(
                level_marker(level=2, color="yellow") + "Found: \n" + colored_print(str(answer), None, "magenta"))
        else:
            emotions.sorry()
            logger.info(level_marker(level=2, color="yellow") + "Couldn't find anything!")

        if sentence.data_type == W_QUESTION:
            self.output_sentence.extend(self.sfactory.create_w_question_answer(sentence,
                                                                               answer,
                                                                               self.question_handler._current_speaker,
                                                                               self.question_handler.get_query_on_field()))

        if sentence.data_type == YES_NO_QUESTION:
            self.output_sentence.extend(self.sfactory.create_yes_no_answer(sentence, answer))

        return stmts, situation_id