summaryrefslogtreecommitdiff
path: root/day1/exercise/word_frequencies.py
diff options
context:
space:
mode:
authorSantosh G. Vattam2010-03-11 18:01:23 +0530
committerSantosh G. Vattam2010-03-11 18:01:23 +0530
commit9638afaff8985d5528cb38842c13cc71cd6cab83 (patch)
tree671a499f31425f35ea158136da94f7a5272749d8 /day1/exercise/word_frequencies.py
parentfb965a5047dca69c518543440c2a6fd5647555c4 (diff)
downloadworkshops-more-scipy-9638afaff8985d5528cb38842c13cc71cd6cab83.tar.gz
workshops-more-scipy-9638afaff8985d5528cb38842c13cc71cd6cab83.tar.bz2
workshops-more-scipy-9638afaff8985d5528cb38842c13cc71cd6cab83.zip
Updated after Day 2 at GRDCS
Diffstat (limited to 'day1/exercise/word_frequencies.py')
-rw-r--r--day1/exercise/word_frequencies.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/day1/exercise/word_frequencies.py b/day1/exercise/word_frequencies.py
index deb9802..1f7351c 100644
--- a/day1/exercise/word_frequencies.py
+++ b/day1/exercise/word_frequencies.py
@@ -1,11 +1,13 @@
-f = open('/home/madhu/pyprogs/pytriads.py')
+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(',.!;?\'" ')
- value = freq.get(key, 1)
- freq[key] = value + 1
+ if key in freq:
+ freq[key] += 1
+ else:
+ freq[key] = 1
print freq