Esempio n. 1
0
    def predict(self, question):
        answer = self._get_answer_to_factoid_question(question)

        msg1 = ["I think that", "It seems that", "I'd like to say that"]
        msg2 = ["correct answer", "answer", "true answer"]
        msg3 = ["is: {}".format(detokenize(normalize(answer))).lower()]
        total_msg = [msg1, msg2, msg3]

        msg = combinate_and_return_answer(total_msg)
        return msg
Esempio n. 2
0
    def predict(self, question):
        answer = self._get_answer_to_factoid_question(question)

        msg1 = ["I think that", "It seems that", "I'd like to say that"]
        msg2 = ["correct answer", "answer", "true answer"]
        msg3 = ["is: {}".format(detokenize(normalize(answer))).lower()]
        total_msg = [msg1, msg2, msg3]

        msg = combinate_and_return_answer(total_msg)
        return msg
Esempio n. 3
0
    def send_message(self, chat_id, text, reply_markup=None):
        text = detokenize(text)
        data = {'text': text, 'evaluation': 0}
        message = {'chat_id': chat_id, 'text': json.dumps(data)}
        logger.info("ConvApiBot#send_message: {}".format(text))

        res = requests.post(os.path.join(self._bot_url, 'sendMessage'),
                            json=message,
                            headers={'Content-Type': 'application/json'})
        if res.status_code != 200:
            logger.warn(res.text)
Esempio n. 4
0
    def send_message(self, chat_id, text, reply_markup=None):
        text = detokenize(text)
        data = {'text': text, 'evaluation': 0}
        message = {'chat_id': chat_id, 'text': json.dumps(data)}
        logger.info("ConvApiBot#send_message: {}".format(text))

        res = requests.post(
            os.path.join(self._bot_url, 'sendMessage'),
            json=message,
            headers={'Content-Type': 'application/json'}
        )
        if res.status_code != 200:
            logger.warn(res.text)
Esempio n. 5
0
    def answer_to_user_question_(self):
        self._cancel_timer_threads()

        answer = self._filter_seq2seq_output(
            self._get_answer_to_factoid_question())

        msg1 = ["I think that", "It seems that", "I'd like to say that"]
        msg2 = ["correct answer", "answer", "true answer"]
        msg3 = ["is: {}".format(detokenize(normalize(answer))).lower()]
        total_msg = [msg1, msg2, msg3]

        msg = combinate_and_return_answer(total_msg)

        self._send_message(msg)
        self.return_to_wait()
Esempio n. 6
0
 def _filter_seq2seq_output(self, s):
     s = normalize(str(s))
     s = detokenize(s)
     return s
Esempio n. 7
0
def combinate_and_return_answer(arr):
    messages_product = list(itertools.product(*arr))
    msg_arr = random.sample(messages_product, 1)[0]
    msg = detokenize(" ".join(msg_arr))
    return msg
Esempio n. 8
0
 def send_message(self, chat_id, text, reply_markup=None):
     text = detokenize(text)
     message = {'chat_id': chat_id, 'text': text}
     logger.info("JsonApiBot#send_message: {}".format(text))
     return message
Esempio n. 9
0
def combinate_and_return_answer(arr):
    messages_product = list(itertools.product(*arr))
    msg_arr = random.sample(messages_product, 1)[0]
    msg = detokenize(" ".join(msg_arr))
    return msg