def censor(self, input_text):
        """Returns input_text with any profane words censored."""
        bad_words = self.get_profane_words()
        res = input_text

        for word in bad_words:
            # Apply word boundaries to the bad word
            regex_string = r'{0}' if self._no_word_boundaries else r'\b{0}\b'
            regex_string = regex_string.format(word)  
            regex = re.compile(regex_string, re.IGNORECASE)
            res = regex.sub(self._censor_char * len(word), res)

        return res
def censor ( self , input_text ) : bad_words = self . get_profane_words ( ) res = input_text for word in bad_words : regex_string = r'{0}' if self . _no_word_boundaries else r'\b{0}\b' regex_string = regex_string . format ( word ) regex = re . compile ( regex_string , re . IGNORECASE ) res = regex . sub ( self . _censor_char * len ( word ) , res ) return res
Returns input_text with any profane words censored.