Esempio n. 1
0
 def test_when_text_is_empty(self):
     cleaner = TextCleaner()
     self.assertEqual(cleaner(u''), u'')
Esempio n. 2
0
 def test_alphabetic(self):
     cleaner = TextCleaner(alphabetic=True)
     self.assertEqual(cleaner(u'Helloo 1984 50,000'), u'Helloo')
Esempio n. 3
0
 def test_only_punctuation(self):
     cleaner = TextCleaner(only_punctuation=True)
     self.assertEqual(cleaner(u'Helloo ? 1984 50,000'), u"?        ,")
Esempio n. 4
0
 def test_filtering_everything(self):
     cleaner = TextCleaner(filter_hashtags=True, filter_urls=True,
                           filter_mentions=True, filter_non_latin=True)
     self.assertEqual(
         cleaner(u'Hello @pasmod #httpe یین http://www.google.de'), u'Hello')
Esempio n. 5
0
 def test_lowercase(self):
     cleaner = TextCleaner(lowercase=True)
     self.assertEqual(cleaner(u'HellO'), u'hello')
Esempio n. 6
0
 def test_filtering_hashtags(self):
     cleaner = TextCleaner(filter_hashtags=True)
     self.assertEqual(cleaner(u'Hello @pasmod #httpe'), u'Hello @pasmod')
Esempio n. 7
0
 def test_filtering_mentions(self):
     cleaner = TextCleaner(filter_mentions=True)
     self.assertEqual(
         cleaner(u'Hello @pasmod http://www.google.de'), u'Hello  http://www.google.de')
Esempio n. 8
0
 def test_filtering_urls(self):
     cleaner = TextCleaner(filter_urls=True)
     self.assertEqual(
         cleaner(u'Hello http://www.google.de bye'), u'Hello  bye')
Esempio n. 9
0
 def test_filtering_non_latin_characters(self):
     cleaner = TextCleaner(filter_non_latin=True)
     self.assertEqual(cleaner(u'Hello عیت world'), u'Hello  world')
Esempio n. 10
0
 def test_default_cleaner_does_nothing(self):
     cleaner = TextCleaner()
     self.assertEqual(cleaner(u'http://www.google.de @pasmod'),
                      u'http://www.google.de @pasmod')