You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#This program parses the dicts that map date to a list of sentiments, and then aggregates them to find date and average sentiment
import pickle
import sys
if len(sys.argv) < 1:
print "Enter a filename as the cmd line argument"
exit()
input_file = str(sys.argv[1])
output_file = "red_" + input_file + ".red"
def average(l):
return sum(l)/float(len(l))
def parse_file(filename):
sent_dict = dict()
with open(filename, 'r') as df:
sent_dict = pickle.load(df)
return sent_dict
#Accept a filename as an argument, create a file called red_<filename>.red, which contains date, average positive sentiment, average negative sentiment.