def generate_tweet_networks(): tp = TweetParser() tweet_file_name = "/Users/vdb5/Documents/research/real world tweets/Seattle raw tweets.txt" network_hash = tp.parse_file(tweet_file_name) print "num sources: ", len(network_hash) print "sample source: ", network_hash.items()[0] nb = NetworkBuilder(network_hash, tweet_file_name) nb.store_network_hash_as_edgefile()
def main(): args = parse_args() client = TwitterAPIClient(args.input) tweet_generator = client.get_tweets() output_file = open(args.output, "w") for tweet in tweet_generator: cleaned_tweet = TweetParser.clean_tweet(tweet) output_file.write("%s (timestamp: %s)\n" % (cleaned_tweet, tweet["created_at"])) output_file.write("\n%d tweets contained unicode.\n" % TweetParser.unicode_count) output_file.close()
def test_clean_tweet(tweet, expected_text, expected_unicode_count): assert TweetParser.clean_tweet(tweet) == expected_text assert TweetParser.unicode_count == expected_unicode_count