Created
July 14, 2014 18:38
-
-
Save ashim888/edf5af269b979965a58f to your computer and use it in GitHub Desktop.
frequency of the word "INTRO TO DATA SCIENCE" TWITTER FREQUENCY COUNT example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import division | |
fuckthis=[['This','fucker','bastard'],['fucker','ok','go','no'],['my','home','is','far'],['hey','you','fucker']] | |
#print len(fuckthis) | |
unique_list=[] | |
my_dict={} | |
def totalwords(): | |
total_words=0 | |
for x in range(0,len(fuckthis)): | |
for y in fuckthis[x]: | |
total_words+=1 | |
if y not in unique_list: | |
unique_list.append(y) | |
print "Total Words: ",total_words | |
print unique_list | |
for x in range(0,len(unique_list)): | |
count=0 | |
for y in range(0,len(fuckthis)): | |
if unique_list[x] in fuckthis[y]: | |
count+=1 | |
my_dict[unique_list[x]]=(count)/(total_words) | |
mylist=my_dict.items() | |
for x in range(0,len(unique_list)): | |
for i in range(0,2): | |
print mylist[x][i] , | |
print "" | |
totalwords() | |
#print my_dict |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment