day1/exercise/word_frequencies.py
author Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
Fri, 18 Jun 2010 01:21:32 -0400
branchscipy2010
changeset 408 217c38c06ebd
parent 380 669b72283b55
permissions -rw-r--r--
ENH: Minor changes to session 2.

f = open('/home/vattam/Desktop/circulate/word-freq/holmes.txt')

freq = {}
for line in f:
    words = line.split()
    for word in words:
        key = word.strip(',.!;?\'" ')
        if key in freq:
            freq[key] += 1
        else:
            freq[key] = 1

print freq