Remove Stop Words


# Load library
from nltk.corpus import stopwords

# You will have to download the set of stop words the first time
import nltk'stopwords')
[nltk_data] Downloading package stopwords to
[nltk_data]     /Users/chrisalbon/nltk_data...
[nltk_data]   Package stopwords is already up-to-date!


Create Word Tokens

# Create word tokens
tokenized_words = ['i', 'am', 'going', 'to', 'go', 'to', 'the', 'store', 'and', 'park']

Load Stop Words

# Load stop words
stop_words = stopwords.words('english')

# Show stop words
['i', 'me', 'my', 'myself', 'we']

Remove Stop Words

# Remove stop words
[word for word in tokenized_words if word not in stop_words]
['going', 'go', 'store', 'park']