Created
March 13, 2010 12:48
-
-
Save lxneng/331304 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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