Esempio n. 1
0
 def get_word_frequency_for_viewpoint(self, viewpoint):
     self.db_cursor.execute("SELECT tweet_text "
                            "FROM tweet "
                            "WHERE viewpoint = %s",
                            (viewpoint,))
     counter = Counter()
     [counter.update(WordCloud.parse_tweet(res.tweet_text)) for res in self.db_cursor]
     return counter
Esempio n. 2
0
 def test_parse_tweet_with_punctuation(self):
     words = WordCloud.parse_tweet(
         "alpha.. “bravo?” charlie’s delta! echo/2")
     self.assertEqual(["alpha", "bravo", "charlie's", "delta", "echo/2"],
                      words)
Esempio n. 3
0
 def test_parse_tweet_upper_case(self):
     words = WordCloud.parse_tweet("ALPHA bravo cHaRlIe")
     self.assertEqual(["alpha", "bravo", "charlie"], words)
Esempio n. 4
0
 def test_parse_tweet_base_case(self):
     words = WordCloud.parse_tweet("alpha bravo charlie")
     self.assertEqual(["alpha", "bravo", "charlie"], words)
Esempio n. 5
0
 def test_parse_tweet_with_short_words(self):
     words = WordCloud.parse_tweet("I am 3 or 4 years")
     self.assertEqual(["am", "or", "years"], words)
Esempio n. 6
0
 def test_parse_tweet_with_links(self):
     words = WordCloud.parse_tweet("alpha https://t.co/randomletters bravo")
     self.assertEqual(["alpha", "https", "bravo"], words)
Esempio n. 7
0
 def test_parse_tweet_with_angle_brackets(self):
     words = WordCloud.parse_tweet("alpha <3 bravo")
     self.assertEqual(["alpha", "&lt;3", "bravo"], words)