コード例 #1
0
    def test_ask_rephrase(self, trained_policy, default_domain):
        events = [ActionExecuted(ACTION_LISTEN_NAME),
                  user_uttered("greet", 0.2),
                  ActionExecuted(ACTION_DEFAULT_ASK_AFFIRMATION_NAME),
                  ActionExecuted(ACTION_LISTEN_NAME),
                  user_uttered('deny', 1)]

        next_action = self._get_next_action(trained_policy, events,
                                            default_domain)

        assert next_action == ACTION_DEFAULT_ASK_REPHRASE_NAME
コード例 #2
0
    def test_unknown_instead_affirmation(self, trained_policy, default_domain):
        events = [ActionExecuted(ACTION_LISTEN_NAME),
                  user_uttered("greet", 0.2),
                  ActionExecuted(ACTION_DEFAULT_ASK_AFFIRMATION_NAME),
                  ActionExecuted(ACTION_LISTEN_NAME),
                  user_uttered("greet", 0.2),
                  ]

        next_action = self._get_next_action(trained_policy, events,
                                            default_domain)

        assert next_action == ACTION_DEFAULT_FALLBACK_NAME
コード例 #3
0
ファイル: test_policies.py プロジェクト: wushanzha/rasa_core
    def test_ask_affirmation(self, trained_policy, default_domain):
        events = [ActionExecuted(ACTION_LISTEN_NAME), user_uttered("Hi", 0.2)]

        next_action = self._get_next_action(trained_policy, events,
                                            default_domain)

        assert next_action == ACTION_DEFAULT_ASK_AFFIRMATION_NAME
コード例 #4
0
ファイル: test_policies.py プロジェクト: prenigma/testfou
    def test_affirm_rephrased_intent(self, trained_policy, default_domain):
        events = [
            ActionExecuted(ACTION_LISTEN_NAME),
            user_uttered("greet", 0.2),
            ActionExecuted(ACTION_DEFAULT_ASK_AFFIRMATION_NAME),
            ActionExecuted(ACTION_LISTEN_NAME),
            user_uttered(USER_INTENT_DENY, 1),
            ActionExecuted(ACTION_DEFAULT_ASK_REPHRASE_NAME),
            ActionExecuted(ACTION_LISTEN_NAME),
            user_uttered("greet", 0.2),
        ]

        next_action = self._get_next_action(trained_policy, events,
                                            default_domain)

        assert next_action == ACTION_DEFAULT_ASK_AFFIRMATION_NAME
コード例 #5
0
ファイル: test_policies.py プロジェクト: wushanzha/rasa_core
    def test_successful_rephrasing(self, trained_policy,
                                   default_dispatcher_collecting,
                                   default_domain):
        events = [
            ActionExecuted(ACTION_LISTEN_NAME),
            user_uttered("greet", 0.2),
            ActionExecuted(ACTION_DEFAULT_ASK_AFFIRMATION_NAME),
            ActionExecuted(ACTION_LISTEN_NAME),
            user_uttered('deny', 1),
            ActionExecuted(ACTION_DEFAULT_ASK_REPHRASE_NAME),
            ActionExecuted(ACTION_LISTEN_NAME),
            user_uttered("bye", 1),
        ]

        tracker = self._get_tracker_after_reverts(
            events, default_dispatcher_collecting, default_domain)

        assert 'bye' == tracker.latest_message.parse_data['intent']['name']
        assert tracker.export_stories() == "## sender\n* bye\n"
コード例 #6
0
def test_last_executed_has_not_name():
    events = [
        ActionExecuted('one'),
        user_uttered('two', 1),
        ActionExecuted(ACTION_LISTEN_NAME)
    ]

    tracker = get_tracker(events)

    assert tracker.last_executed_action_has('another') is False
コード例 #7
0
    def test_affirmation(self, default_dispatcher_collecting, default_domain):
        events = [ActionExecuted(ACTION_LISTEN_NAME),
                  user_uttered('greet', 1),
                  ActionExecuted('utter_hello'),
                  ActionExecuted(ACTION_LISTEN_NAME),
                  user_uttered('greet', 0.2),
                  ActionExecuted(ACTION_DEFAULT_ASK_AFFIRMATION_NAME),
                  ActionExecuted(ACTION_LISTEN_NAME),
                  user_uttered('greet', 1)]

        tracker = self._get_tracker_after_reverts(events,
                                                  default_dispatcher_collecting,
                                                  default_domain)

        assert 'greet' == tracker.latest_message.parse_data['intent']['name']
        assert tracker.export_stories() == ("## sender\n"
                                            "* greet\n"
                                            "    - utter_hello\n"
                                            "* greet\n")
コード例 #8
0
def test_get_last_event_for_with_skip():
    events = [
        ActionExecuted('one'),
        user_uttered('two', 1),
        ActionExecuted('three')
    ]

    tracker = get_tracker(events)

    assert (tracker.get_last_event_for(ActionExecuted,
                                       skip=1).action_name == 'one')
コード例 #9
0
def test_get_last_event_for_with_exclude():
    events = [
        ActionExecuted('one'),
        user_uttered('two', 1),
        ActionExecuted('three')
    ]

    tracker = get_tracker(events)

    assert (tracker.get_last_event_for(
        ActionExecuted,
        action_names_to_exclude=['three']).action_name == 'one')
コード例 #10
0
ファイル: test_policies.py プロジェクト: wushanzha/rasa_core
    def test_rephrasing_instead_affirmation(self, trained_policy,
                                            default_dispatcher_collecting,
                                            default_domain):
        events = [
            ActionExecuted(ACTION_LISTEN_NAME),
            user_uttered("greet", 1),
            ActionExecuted("utter_hello"),
            ActionExecuted(ACTION_LISTEN_NAME),
            user_uttered("greet", 0.2),
            ActionExecuted(ACTION_DEFAULT_ASK_AFFIRMATION_NAME),
            ActionExecuted(ACTION_LISTEN_NAME),
            user_uttered("bye", 1),
        ]

        tracker = self._get_tracker_after_reverts(
            events, default_dispatcher_collecting, default_domain)

        assert 'bye' == tracker.latest_message.parse_data['intent']['name']
        assert tracker.export_stories() == ("## sender\n"
                                            "* greet\n"
                                            "    - utter_hello\n"
                                            "* bye\n")
コード例 #11
0
def test_get_last_event_with_reverted():
    events = [ActionExecuted('one'), ActionReverted(), user_uttered('two', 1)]

    tracker = get_tracker(events)

    assert tracker.get_last_event_for(ActionExecuted) is None
コード例 #12
0
def test_get_last_event_for():
    events = [ActionExecuted('one'), user_uttered('two', 1)]

    tracker = get_tracker(events)

    assert tracker.get_last_event_for(ActionExecuted).action_name == 'one'