Skip to content

Instantly share code, notes, and snippets.

@lizadaly
lizadaly / example-bigrams.py
Last active August 31, 2020 12:18
Quick bigram example in Python/NLTK
import nltk
from nltk.corpus import stopwords
from collections import Counter
word_list = []
# Set up a quick lookup table for common words like "the" and "an" so they can be excluded
stops = set(stopwords.words('english'))
# For all 18 novels in the public domain book corpus, extract all their words