Created
April 19, 2013 20:49
-
-
Save marcelcaraciolo/5423131 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re import math | |
def getwords(doc): | |
splitter=re.compile('\\W*') # Split the words by non-alpha characters | |
words=[s.lower() for s in splitter.split(doc) if len(s)>2 and len(s)<20] | |
# Return the unique set of words only | |
return dict([(w,1) for w in words]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment