示例#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
def main():
    community = read_output('pickled_populations/lizardbill_11_20_2010')
    s = PopulationStats(community['members'])
    community_member_names = s.all_user_names()
    for user in community['members']:
        print ''
        print 'User:'******'screen_name']
        print 'ID:', user['uid']
        print 'Tweet Count:', len(user['tweets'])
        print 'Friend IDs:', len(user['friend_ids'])
        print 'Follower IDs:', len(user['follower_ids'])
    print 'Community Members:', len(community['members'])
示例#4
0
 def _empty_user_score(self, user_id):
     '''The score for a user_id.'''
     if self._community:
         stats = PopulationStats(self._community_members)
         community_friend_ids = stats.all_relation('friend_ids')
         friended = community_friend_ids.count(user_id)
         community_follow_ids = stats.all_relation('follower_ids')
         followed = community_follow_ids.count(user_id)
         score = friended + followed
     else:
         score = 0
     return 0
def main():
    community = read_output('pickled_populations/lizardbill_11_20_2010')
    s = PopulationStats(community['members'])
    community_member_names = s.all_user_names()
    for user in community['members']:
        print ''
        print 'User:'******'screen_name']
        print 'ID:', user['uid']
        print 'Tweet Count:', len(user['tweets'])
        print 'Friend IDs:', len(user['friend_ids'])
        print 'Follower IDs:', len(user['follower_ids'])
    print 'Community Members:', len(community['members'])
示例#6
0
 def _empty_user_score(self, user_id):
     '''The score for a user_id.'''
     if self._community:
         stats = PopulationStats(self._community_members)
         community_friend_ids = stats.all_relation('friend_ids')
         friended = community_friend_ids.count(user_id)
         community_follow_ids = stats.all_relation('follower_ids')
         followed = community_follow_ids.count(user_id)
         score = friended + followed
     else:
         score = 0
     return 0