def test_leading_or_trailing_whitespace_removed(self): text = ' The quick brown fox jumps over the lazy dog. ' clean_text = clean_whitespace(text) normal_text = 'The quick brown fox jumps over the lazy dog.' self.assertEqual(clean_text, normal_text)
def test_consecutive_spaces_removed(self): text = 'The quick brown fox jumps over the lazy dog.' clean_text = clean_whitespace(text) normal_text = 'The quick brown fox jumps over the lazy dog.' self.assertEqual(clean_text, normal_text)
def remove_mentions(self, text): """ Return a string that has no leading mentions. """ import re from chatterbot.utils.clean import clean_whitespace text_without_mentions = re.sub(r'@\S+', '', text) return clean_whitespace(text_without_mentions)
def remove_mentions(self, text): """ Return a string that has no leading mentions. """ import re from chatterbot.utils.clean import clean_whitespace text_without_mentions = re.sub(r"@\S+", "", text) return clean_whitespace(text_without_mentions)
def clean_text(self, text): # Remove user mentions text = re.sub(r'@\S+', '', text) text = self.remove_punctuation(text) # Remove extre whitespace text = clean_whitespace(text) # Return the lowercase text return text.lower()
def test_clean_whitespace(self): text = '\tThe quick \nbrown fox \rjumps over \vthe \alazy \fdog\\.' clean_text = clean_whitespace(text) normal_text = 'The quick brown fox jumps over \vthe \alazy \fdog\\.' self.assertEqual(clean_text, normal_text)