day1/exercise/kwfreq.py
author Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
Mon, 21 Jun 2010 03:47:30 -0400
branchscipy2010
changeset 418 94955d4900d0
parent 380 669b72283b55
permissions -rw-r--r--
Merging changes from Chris.

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

print freq