Skip to content

Instantly share code, notes, and snippets.

@language-engineering
Last active October 11, 2015 13:27
Show Gist options
  • Select an option

  • Save language-engineering/3865355 to your computer and use it in GitHub Desktop.

Select an option

Save language-engineering/3865355 to your computer and use it in GitHub Desktop.
from nltk.probability import FreqDist
from sussex_nltk.corpus_readers import AmazonReviewCorpusReader
#Helper function. Given a list of reviews, return a list of all the words in those reviews
def get_all_words(amazon_reviews):
return reduce(lambda words,review: words + review.words(), amazon_reviews, [])
#A frequency distribution over all words in positive book reviews
pos_book_freqdist = FreqDist(get_all_words(pos_training_data))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment