day1/exercise/kwfreq.py
author Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
Thu, 17 Jun 2010 16:10:54 -0400
branchscipy2010
changeset 406 59ac23362859
parent 380 669b72283b55
permissions -rw-r--r--
Merging Chris and my changes.

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