Beispiel #1
0
    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)
Beispiel #2
0
    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)
Beispiel #3
0
    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)
Beispiel #4
0
    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)
Beispiel #5
0
 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)
Beispiel #6
0
    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)
Beispiel #7
0
    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()
Beispiel #8
0
    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)
Beispiel #9
0
    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)