day1/exercise/word_frequencies.py
author Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
Mon, 21 Jun 2010 03:40:59 -0400
branchscipy2010
changeset 417 caec361e3a86
parent 380 669b72283b55
permissions -rw-r--r--
ENH: Added slides for FFT and basic signal processing, wherein we introduce some random number generation also. Misc. cleanup for tutorial.

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