def __db_trustworthy_users(db_users, db_tweets, config): """ Generate a database of trustworthy users. We trust in the user if she has a verified account or has more than X number of followers :param db_users: database of user :param config: dictionary with the configuration parameters of the heuristic :return: database of trustworthy users """ trustworthy_users_db = DBManager('trustworthy_users') if trustworthy_users_db.num_records_collection() == 0: logging.info('The trustworthy_users collection is being created...') for doc in db_users.find_all(): data = get_user(db_tweets, doc['screen_name']) if data['verified'] or int( data['followers_count']) > config['min_num_followers']: if not trustworthy_users_db.find_record( {'screen_name': data['screen_name']}): trustworthy_users_db.save_record({ 'screen_name': doc['screen_name'], 'name': data['name'], 'created_at': data['created_at'], 'followers_count': data['followers_count'], 'verified': data['verified'] }) return trustworthy_users_db
def run_bot_detector(users, reusedb, fakepromoter): bot_detector = BotDetector() # create database of user if it doesn't exist users_db = DBManager('users') if users_db.num_records_collection() == 0: na = NetworkAnalyzer() na.create_users_db() bot_detector.compute_bot_probability(users, 'users', reusedb) if fakepromoter: bot_detector.compute_fake_promoter_heuristic(users)