Skip to content

Instantly share code, notes, and snippets.

@ashim888
Created July 14, 2014 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashim888/edf5af269b979965a58f to your computer and use it in GitHub Desktop.
Save ashim888/edf5af269b979965a58f to your computer and use it in GitHub Desktop.
frequency of the word "INTRO TO DATA SCIENCE" TWITTER FREQUENCY COUNT example
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