rasa/core/channels/slack.py
def _sanitize_user_message(text, uids_to_remove):
        """Remove superfluous/wrong/problematic tokens from a message.

        Probably a good starting point for pre-formatting of user-provided text
        to make NLU's life easier in case they go funky to the power of extreme

        In the current state will just drop self-mentions of bot itself

        Args:
            text: raw message as sent from slack
            uids_to_remove: a list of user ids to remove from the content

        Returns:
            str: parsed and cleaned version of the input text
        """
        for uid_to_remove in uids_to_remove:
            # heuristic to format majority cases OK
            # can be adjusted to taste later if needed,
            # but is a good first approximation
            for regex, replacement in [(r'<@{}>\s'.format(uid_to_remove), ''),
                                       (r'\s<@{}>'.format(uid_to_remove), ''),
                                       # a bit arbitrary but probably OK
                                       (r'<@{}>'.format(uid_to_remove), ' ')]:
                text = re.sub(regex, replacement, text)

        return text.rstrip().lstrip()
Remove superfluous/wrong/problematic tokens from a message.

        Probably a good starting point for pre-formatting of user-provided text
        to make NLU's life easier in case they go funky to the power of extreme

        In the current state will just drop self-mentions of bot itself

        Args:
            text: raw message as sent from slack
            uids_to_remove: a list of user ids to remove from the content

        Returns:
            str: parsed and cleaned version of the input text
        
Remove superfluous/wrong/problematic tokens from a message.
Probably a good starting point for pre-formatting of user-provided text
to make NLU's life easier in case they go funky to the power of extreme

In the current state will just drop self-mentions of bot itself
Remove superfluous / wrong / problematic tokens from a message . Probably a good starting point for pre - formatting of user - provided text to make NLU ' s life easier in case they go funky to the power of extreme In the current state will just drop self - mentions of bot itself
def _sanitize_user_message(text, uids_to_remove):
        for uid_to_remove in uids_to_remove:
            for regex, replacement in [(r'<@{}>\s'.format(uid_to_remove), ''),
                                       (r'\s<@{}>'.format(uid_to_remove), ''),
                                       (r'<@{}>'.format(uid_to_remove), ' ')]:
                text = re.sub(regex, replacement, text)
        return text.rstrip().lstrip()
def _sanitize_user_message ( text , uids_to_remove ) : for uid_to_remove in uids_to_remove : for regex , replacement in [ ( r'<@{}>\s' . format ( uid_to_remove ) , '' ) , ( r'\s<@{}>' . format ( uid_to_remove ) , '' ) , ( r'<@{}>' . format ( uid_to_remove ) , ' ' ) ] : text = re . sub ( regex , replacement , text ) return text . rstrip ( ) . lstrip ( )
Remove superfluous/wrong/problematic tokens from a message.
Remove superfluous / wrong / problematic tokens from a message .
"""Remove superfluous/wrong/problematic tokens from a message.

        Probably a good starting point for pre-formatting of user-provided text
        to make NLU's life easier in case they go funky to the power of extreme

        In the current state will just drop self-mentions of bot itself

        Args:
            text: raw message as sent from slack
            uids_to_remove: a list of user ids to remove from the content

        Returns:
            str: parsed and cleaned version of the input text
        """ # heuristic to format majority cases OK # can be adjusted to taste later if needed, # but is a good first approximation # a bit arbitrary but probably OK
parsed and cleaned version of the input text
parsed and cleaned version of the input text
str
text
raw message as sent from slack
raw message as sent from slack
uids_to_remove
a list of user ids to remove from the content
a list of user ids to remove from the content