示例#1
0
    def _filled_user_score(self, user):
        '''The score for a user for where user is the result of a TwitterUser object.'''
        if self._community:
            pop_stats = PopulationStats(self._community_members)
            community_member_ids = pop_stats.all_user_ids()
            #num of user's followers/friends in the community
            friend_overlap = len(self._intersection(user['friend_ids'], \
              community_member_ids))
            try:
                friend_percent_overlap = friend_overlap/user['friend_count']
            except ZeroDivisionError:
                friend_percent_overlap = 0
            follower_overlap = len(self._intersection(user['follower_ids'], \
              community_member_ids))
            try:
                follower_percent_overlap = follower_overlap/user['follower_count']
            except ZeroDivisionError:
                follower_percent_overlap = 0

            reply_score = 0
            user_stats = UserStats(user, self._community_members)
            replies = user_stats.replies()
            member_ids = [user['uid'] for user in self._community_members]
            for replying_to in replies:
                if replying_to in member_ids:
                    reply_score += 1
            score = follower_percent_overlap + friend_percent_overlap
            #+ reply_score
        else:
            score = 0
        return score
示例#2
0
    def _filled_user_score(self, user):
        '''The score for a user for where user is the result of a TwitterUser object.'''
        if self._community:
            pop_stats = PopulationStats(self._community_members)
            community_member_ids = pop_stats.all_user_ids()
            #num of user's followers/friends in the community
            friend_overlap = len(self._intersection(user['friend_ids'], \
              community_member_ids))
            try:
                friend_percent_overlap = friend_overlap / user['friend_count']
            except ZeroDivisionError:
                friend_percent_overlap = 0
            follower_overlap = len(self._intersection(user['follower_ids'], \
              community_member_ids))
            try:
                follower_percent_overlap = follower_overlap / user[
                    'follower_count']
            except ZeroDivisionError:
                follower_percent_overlap = 0

            reply_score = 0
            user_stats = UserStats(user, self._community_members)
            replies = user_stats.replies()
            member_ids = [user['uid'] for user in self._community_members]
            for replying_to in replies:
                if replying_to in member_ids:
                    reply_score += 1
            score = follower_percent_overlap + friend_percent_overlap
            #+ reply_score
        else:
            score = 0
        return score
示例#3
0
 def test_user_stats_formating(self):
     user_stats = UserStats()
     user_stats["bodiky"] += 1
     self.assertEqual(user_stats._get_stats_str(), "  bodiky = 1\n")
     user_stats["neco"] += 8
     self.assertIn("  neco = 8\n", user_stats._get_stats_str())
示例#4
0
 def test_user_stats(self):
     user_stats = UserStats()
     user_stats["bodiky"] += 1
     self.assertEqual(user_stats["bodiky"], 1)