rasa/core/policies/mapping_policy.py
def predict_action_probabilities(self,
                                     tracker: DialogueStateTracker,
                                     domain: Domain) -> List[float]:
        """Predicts the assigned action.

        If the current intent is assigned to an action that action will be
        predicted with the highest probability of all policies. If it is not
        the policy will predict zero for every action."""

        prediction = [0.0] * domain.num_actions
        intent = tracker.latest_message.intent.get('name')
        action = domain.intent_properties.get(intent, {}).get('triggers')
        if tracker.latest_action_name == ACTION_LISTEN_NAME:
            if action:
                idx = domain.index_for_action(action)
                if idx is None:
                    logger.warning("MappingPolicy tried to predict unkown "
                                   "action '{}'.".format(action))
                else:
                    prediction[idx] = 1
            elif intent == USER_INTENT_RESTART:
                idx = domain.index_for_action(ACTION_RESTART_NAME)
                prediction[idx] = 1
            elif intent == USER_INTENT_BACK:
                idx = domain.index_for_action(ACTION_BACK_NAME)
                prediction[idx] = 1
        elif tracker.latest_action_name == action and action is not None:
            latest_action = tracker.get_last_event_for(ActionExecuted)
            assert latest_action.action_name == action

            if latest_action.policy == type(self).__name__:
                # this ensures that we only predict listen, if we predicted
                # the mapped action
                idx = domain.index_for_action(ACTION_LISTEN_NAME)
                prediction[idx] = 1
        return prediction
Predicts the assigned action.

        If the current intent is assigned to an action that action will be
        predicted with the highest probability of all policies. If it is not
        the policy will predict zero for every action.
Predicts the assigned action.
If the current intent is assigned to an action that action will be
predicted with the highest probability of all policies. If it is not
the policy will predict zero for every action.
Predicts the assigned action . If the current intent is assigned to an action that action will be predicted with the highest probability of all policies . If it is not the policy will predict zero for every action .
def predict_action_probabilities(self,
                                     tracker: DialogueStateTracker,
                                     domain: Domain) -> List[float]:
        prediction = [0.0] * domain.num_actions
        intent = tracker.latest_message.intent.get('name')
        action = domain.intent_properties.get(intent, {}).get('triggers')
        if tracker.latest_action_name == ACTION_LISTEN_NAME:
            if action:
                idx = domain.index_for_action(action)
                if idx is None:
                    logger.warning("MappingPolicy tried to predict unkown "
                                   "action '{}'.".format(action))
                else:
                    prediction[idx] = 1
            elif intent == USER_INTENT_RESTART:
                idx = domain.index_for_action(ACTION_RESTART_NAME)
                prediction[idx] = 1
            elif intent == USER_INTENT_BACK:
                idx = domain.index_for_action(ACTION_BACK_NAME)
                prediction[idx] = 1
        elif tracker.latest_action_name == action and action is not None:
            latest_action = tracker.get_last_event_for(ActionExecuted)
            assert latest_action.action_name == action
            if latest_action.policy == type(self).__name__:
                idx = domain.index_for_action(ACTION_LISTEN_NAME)
                prediction[idx] = 1
        return prediction
def predict_action_probabilities ( self , tracker : DialogueStateTracker , domain : Domain ) -> List [ float ] : prediction = [ 0.0 ] * domain . num_actions intent = tracker . latest_message . intent . get ( 'name' ) action = domain . intent_properties . get ( intent , { } ) . get ( 'triggers' ) if tracker . latest_action_name == ACTION_LISTEN_NAME : if action : idx = domain . index_for_action ( action ) if idx is None : logger . warning ( "MappingPolicy tried to predict unkown " "action '{}'." . format ( action ) ) else : prediction [ idx ] = 1 elif intent == USER_INTENT_RESTART : idx = domain . index_for_action ( ACTION_RESTART_NAME ) prediction [ idx ] = 1 elif intent == USER_INTENT_BACK : idx = domain . index_for_action ( ACTION_BACK_NAME ) prediction [ idx ] = 1 elif tracker . latest_action_name == action and action is not None : latest_action = tracker . get_last_event_for ( ActionExecuted ) assert latest_action . action_name == action if latest_action . policy == type ( self ) . __name__ : idx = domain . index_for_action ( ACTION_LISTEN_NAME ) prediction [ idx ] = 1 return prediction
Predicts the assigned action.
Predicts the assigned action .
"""Predicts the assigned action.

        If the current intent is assigned to an action that action will be
        predicted with the highest probability of all policies. If it is not
        the policy will predict zero for every action.""" # this ensures that we only predict listen, if we predicted # the mapped action
self
tracker
DialogueStateTracker
domain
Domain