Advertisement
ijontichy

well that was easy

Sep 29th, 2012
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. def wordCounts(self, revision=-1):
  2. pageCrap = NOTAGRE.sub("", self.getHTML(revision))
  3. ret = collections.defaultdict(int)
  4.  
  5. for word in pageCrap:
  6. per = set()
  7.  
  8. for i in range(len(word)):
  9. for j in range(i+1, len(word)+1):
  10. per |= {word[i:j]}
  11.  
  12. for i in per:
  13. ret[i] += 1
  14.  
  15. return dict(ret)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement