Exemplo n.º 1
0
    def setUp(self):
        tweets_one = [
            build_tweet(text="hola a todos", user_id="1"),
            build_tweet(text="#BuenViernes todos, hola a! Buen Viernes",
                        user_id="2"),
        ]
        tweets_two = [
            build_tweet(text="a todos, hola", user_id="1"),
        ]

        fd1, users1 = get_counters(tweets_one)
        fd2, users2 = get_counters(tweets_two)

        self.fd, self.users = merge_counters([fd1, fd2], [users1, users2])
Exemplo n.º 2
0
    def test_one_tweet_generate_freqdist_counts(self):
        tweets = [build_tweet("hola a todos, hola", user_id="1234")]

        fd, _ = get_counters(tweets)

        self.assertEqual(dict(fd), {
            "a": 1,
            "hola": 2,
            "todos": 1,
        })
Exemplo n.º 3
0
    def test_one_tweet_generate_users_dict(self):
        tweets = [build_tweet("hola a todos, hola", user_id="1234")]

        _, users = get_counters(tweets)

        self.assertDictEqual(users, {
            "hola": {"1234"},
            "a": {"1234"},
            "todos": {"1234"}
        })
Exemplo n.º 4
0
    def test_tweets_with_repeated_letters(self):
        tweets = [
            build_tweet("holaaaaa", user_id="1234"),
            build_tweet("holaaaaaaaaaa", user_id="1234"),
        ]

        _, users = get_counters(tweets)

        self.assertDictEqual(users, {
            "holaaa": {"1234"},
        })
Exemplo n.º 5
0
    def test_two_tweets_frequency(self):
        tweets = [
            build_tweet("hola a todos, hola #BuenMiercoles", user_id="1234"),
            build_tweet("hola amigos especialmente a @johndoe",
                        user_id="12345")
        ]

        fd, _ = get_counters(tweets)

        self.assertEqual(dict(fd), {
            "a": 2,
            "hola": 3,
            "todos": 1,
            "amigos": 1,
            "especialmente": 1
        })