Example #1
0
    def test_get_reply_template_lack_para_ask(self):
        default_state=0
        last_state_id=98
        intent_record=IntentRecord(
            self.TEST_INTENT_ID, self.LACK_PARA_STATE_ID)
        intent=Intent(
            self.TEST_INTENT_ID,
            'test_domain',
            default_state,
            {},
            [IntentParameter('test_keyword_name', 'test_para', 'ask', 2, 're_ask', None, 'string')])
        context_manager=ContextManager()
        result=context_manager.get_reply_template(
            intent, intent_record, last_state_id)

        self.assertEqual('ask', result)
Example #2
0
    def test_get_reply_template_no_para_default_reply(self):
        last_state_id=0
        from_state_id=99
        intent_record=IntentRecord(self.TEST_INTENT_ID, from_state_id)
        intent_record.user_paramenters={
            'test_para': ['test_value', 'test_value2']}
        intent = Intent(
            self.TEST_INTENT_ID,
            'test_domain',
            from_state_id,
            {(from_state_id, None): ['test_reply']},
            [IntentParameter('test_keyword_name', 'test_para', 'ask', 2, 're_ask', None, 'string')])
        context_manager=ContextManager()
        result=context_manager.get_reply_template(
            intent, intent_record, last_state_id)

        self.assertEqual('test_reply', result)
Example #3
0
    def test_state_transition_multi_value_slot_less_than_max_but_stop(self):
        from_state_id=99
        to_state_id=100
        engine_query_result=EngineQueryResult(
            self.TEST_INTENT_ID, self.DETERMINISTIC_RESULT_PROB, to_state_id, {}, [])
        intent_record=IntentRecord(self.TEST_INTENT_ID, from_state_id)
        intent_record.user_paramenters={'test_para': ['test_value']}
        intent=Intent(
            self.TEST_INTENT_ID,
            'test_domain',
            from_state_id,
            {(from_state_id, from_state_id): 'test_reply'},
            [IntentParameter('test_keyword_name', 'test_para', 'ask', 2, 're_ask', None, 'string')])
        context_manager=ContextManager()
        result=context_manager.state_transition(
            engine_query_result, intent_record, intent, True)

        self.assertEqual(self.TEST_INTENT_ID, result.intent_id)
        self.assertEqual(self.PARA_SATISFIED_STATE_ID, result.state_id)
Example #4
0
    def test_state_transition_None_to_parameter_not_satisfied(self):
        from_state_id = 99
        to_state_id = 100
        engine_query_result = EngineQueryResult(
            self.TEST_INTENT_ID, self.DETERMINISTIC_RESULT_PROB, to_state_id, {}, [])
        intent_record = IntentRecord(self.TEST_INTENT_ID, from_state_id)
        intent=Intent(
            self.TEST_INTENT_ID,
            'test_domain',
            from_state_id,
            {(from_state_id, from_state_id): 'test_reply'},
            [IntentParameter('test_keyword_name', 'test_para', 'ask', 1, None, None, 'string')])
            
        context_manager=ContextManager()
        result=context_manager.state_transition(
            engine_query_result, intent_record, intent, False)

        self.assertEqual(self.TEST_INTENT_ID, result.intent_id)
        self.assertEqual(self.LACK_PARA_STATE_ID, result.state_id)
Example #5
0
 def parameter_dic_to_object():
     return [
         IntentParameter(p[0], p[2], p[3], p[4], p[5], p[6], p[7])
         for p in this_intent_parameter_list
     ]