Skip to content

Instantly share code, notes, and snippets.

@language-engineering
Created September 14, 2012 14:17
Show Gist options
  • Save language-engineering/3722175 to your computer and use it in GitHub Desktop.
Save language-engineering/3722175 to your computer and use it in GitHub Desktop.
from sussex_nltk.corpus_readers import AmazonReviewCorpusReader #import reader class
arcr = AmazonReviewCorpusReader() #create new reader
positive_reviews = arcr.positive() #store a reader pointing at all positive reviews
negative_reviews = arcr.negative() #pointing at all negative
dvd_reviews = arcr.category("dvd") #pointing at all dvd
positive_dvd_reviews = dvd_reviews.positive() #pointing at all postive dvd
#get a sample of the tokens in positive dvd reviews using your 5-digit candidate number
tokens = positive_dvd_reviews.sample_words(12345)
for token in tokens: #iterate over the tokens
print token #print each token
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment