author | Shantanu <shantanu@fossee.in> |
Fri, 20 Nov 2009 00:34:18 +0530 | |
changeset 321 | 8bf99f747817 |
parent 180 | e442b9e23972 |
child 380 | 669b72283b55 |
permissions | -rw-r--r-- |
64
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
1 |
import keyword |
180
e442b9e23972
Made English and low level id changes to session1.tex
rivermaker@RivermakerMBP.local
parents:
86
diff
changeset
|
2 |
f = open('amicable.py') |
64
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
3 |
|
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
4 |
freq = {} |
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
5 |
for line in f: |
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
6 |
words = line.split() |
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
7 |
for word in words: |
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
8 |
key = word.strip(',.!;?()[]: ') |
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
9 |
if keyword.iskeyword(key): |
180
e442b9e23972
Made English and low level id changes to session1.tex
rivermaker@RivermakerMBP.local
parents:
86
diff
changeset
|
10 |
if key in freq: |
e442b9e23972
Made English and low level id changes to session1.tex
rivermaker@RivermakerMBP.local
parents:
86
diff
changeset
|
11 |
freq[key] += 1 |
e442b9e23972
Made English and low level id changes to session1.tex
rivermaker@RivermakerMBP.local
parents:
86
diff
changeset
|
12 |
else: |
e442b9e23972
Made English and low level id changes to session1.tex
rivermaker@RivermakerMBP.local
parents:
86
diff
changeset
|
13 |
freq[key] = 1 |
64
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
14 |
|
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
15 |
print freq |
333092b68926
Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
16 |