Created
April 8, 2013 10:37
-
-
Save beauvais/5335853 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
from nltk import * | |
from nltk.corpus import stopwords | |
filename = 'tweets.txt' | |
def txt_to_nltk(filename): | |
raw = open(filename, 'rU').read() | |
tokens = word_tokenize(raw) | |
words = [w.lower() for w in tokens] | |
vocab = sorted(set(words)) | |
cleaner_tokens = wordpunct_tokenize(raw) | |
filtered_words = [w for w in cleaner_tokens if not w in stopwords.words('english')] | |
tweets = Text(tokens) | |
mining_tweets = Text(filtered_words) | |
txt_to_nltk(filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment