#Test 6: Comparing Timestamps
print 'TEST 6: Comparing Timestamps'
print tweetLibrary.compare_timestamps(tweet_1,tweet_4)
print tweetLibrary.compare_timestamps(tweet_1,tweet_2)

#Test 7: Get an array of all hashtags
all_hashtags = [['#hi', '#hello'],['#I', '#love', '#you'], ['#you', '#are', '#great'], ['#hello', '#you']]
tweetLibrary.unique_hashtags(all_hashtags)

#Test 8: Get the hashtag dictionary
print 'TEST 8: Getting the hashtag dictionary'
unique_hashtags = tweetLibrary.unique_hashtags(all_hashtags)
#tweetLibrary.get_hashtag_dictionary(all_hashtags)
hashtags_1 = tweetLibrary.extract_hashtags(tweet_6)
hashtags_2 = tweetLibrary.extract_hashtags(tweet_7)
tweetLibrary.get_hashtag_dictionary(hashtags_1)
tweetLibrary.get_hashtag_dictionary(hashtags_2)
tweets_hashtags = []
for i in range(0,200):
	tweets_hashtags.append(tweetLibrary.extract_hashtags(tweetLibrary.get_tweet_text(tweetLibrary.decode_tweet(tweets[i]))))
sample_dictionary = tweetLibrary.get_hashtag_dictionary(tweets_hashtags)
# print sample_dictionary

#Test 9: Find the degree of a hashtag
print 'TEST 9: Find the degree of a hashtag'
print tweetLibrary.get_hashtag_degree(sample_dictionary,'#Jobs') == 6
print tweetLibrary.get_hashtag_degree(sample_dictionary,'#hiring!') == 6
print tweetLibrary.get_hashtag_degree(sample_dictionary,'#LaLiga') == 1


#Test 10: Find average degree of a collection of hashtags 
tweets = open('tweets.txt')
tweets = tweets.readlines()
tweet_timestamps = []
tweet_hashtags = []
output = open('tweet_output/ft2.txt', 'w') 

for i in range(0,len(tweets)):
	tweet = tweetLibrary.decode_tweet(tweets[i])
	tweet_timestamps.append(int(tweetLibrary.get_ms_timestamp(tweet)))
	tweet_hashtags.append(tweetLibrary.extract_hashtags(tweetLibrary.get_tweet_text(tweet)))

current_timestamps=[]
lowest_index = 0
for i in range(1,len(tweet_timestamps)):
	current_timestamps.append(tweet_timestamps[i]) 
	print i 
	#lowest_index is the lowest index of current_timestamps where the element at that index is
	#within 60 seconds of element i 
	lowest_index = tweetLibrary.compare_timestamp_list(current_timestamps)
	del current_timestamps[0:lowest_index]
	current_hashtags = tweet_hashtags[i-len(current_timestamps):i]
	output.write('Current average degree:')
	output.write(str(tweetLibrary.get_average_degree(tweetLibrary.get_hashtag_dictionary(current_hashtags))))
	output.write('\n')


output.close()