Advertisement
r4yan2

Untitled

Oct 27th, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. #!/usr/bin/python
  2. # -*- coding: iso-8859-15 -*-
  3. import re
  4. import os, sys
  5. file=open("/home/r4yan2/Downloads/divina_commedia.txt","r+")
  6. wordcount={}
  7. for word in file.read().split(s):
  8. word=re.sub('[^A-Za-z0-9\']+', '', word.lower())
  9. if word not in wordcount:
  10. wordcount[word] = 1
  11. else:
  12. wordcount[word] += 1
  13. for k,v in wordcount.items():
  14. print k, v
  15. ~
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement