def liwc_results(str, _name): liwc_lexicon = Liwc() #Count the number of words in each Category category_counts = Counter(liwc_lexicon.read_document(str)) print 'Basic category counts: {}'.format(category_counts) #Calculate the score for each category full_counts = liwc_lexicon.summarize_document(str) liwc_lexicon.print_summarization(full_counts, _name)
print "TODO: upload the LIWC analysis result to the user prof entry? No LIWC should be done on a static set" for username in usernames: results = tweets.find({'user.screen_name': username}) textmass = "" for result in results: textmass = textmass + " " + result['text'].encode('utf8') #textmass = unicode( textmass, errors='ignore') textmass = ' '.join(re.sub("(@[A-Za-z0-9]+)|([^0-9A-Za-z \t])|(\w+:\/\/\S+)"," ",textmass).split()) # outfile = open(username + ".txt","w") # outfile.write(textmass) # outfile.close() textmass.lower() result = Liwc.summarize_document(liwc, textmass) Liwc.print_summarization(liwc, result) #infilename = "all_text_Content.txt" #infilename = "lincoln.txt" # #infile = open(infilename,"r") #sample = "" # #for line in infile: # sample = sample + " " + line # #liwc = Liwc() #result = Liwc.summarize_document(liwc, sample) #Liwc.print_summarization(liwc, result)