Removing stopwords with NLTK

Code with explanations:

Python
import nltk
from nltk.corpus import stopwords
from nltk.tokenize import sent_tokenize, word_tokenize

# might not be necessary
# https://www.nltk.org/api/nltk.downloader.html?highlight=download
nltk.download('stopwords')

# stopwords are a "Word List"
# https://www.nltk.org/howto/corpus.html#word-lists-and-lexicons
stop_words = set(stopwords.words('english'))
print(stop_words)

"""
{'does', 'if', 'until', 'under', 'no', 'that', 'own', "don't", 'what', 'off', 'did', 'few', 'being', 'my', 'shan', 'were', 'most', 'him', 'but', 'wouldn', 'there', 've', 'isn', "it's", 'ourselves', 'he', 'so', "needn't", 'then', 're', 'after', 'be', 'couldn', 'those', "you're", 'won', 'should', "mustn't", 'into', 'is', "weren't", 'before', 'whom', 'y', 'don', 'didn', 'theirs', 'you', 'i', 'too', 'been', 'a', "wasn't", 'can', 'how', 'just', "should've", 'about', 'and', "mightn't", 'wasn', 'other', 'are', 'll', 'will', 'now', 'or', 'our', 'at', 's', 'by', 'had', "that'll", 'an', 'have', 'to', "you'd", 'again', 'more', 'its', 'haven', "won't", 'down', "shouldn't", 'his', 'we', 'm', 'aren', 'them', 'doesn', 'once', 'ma', 'weren', 'on', 't', 'the', 'himself', 'o', 'as', 'below', 'between', 'such', 'which', 'was', "wouldn't", 'hadn', "couldn't", "doesn't", 'ain', 'against', "hasn't", 'here', 'while', 'above', 'only', 'any', "she's", 'where', 'this', 'of', 'having', "you'll", 'with', 'mustn', 'through', "shan't", 'yourselves', 'yourself', 'same', 'hers', "haven't", 'in', 'mightn', "didn't", "hadn't", 'they', 'why', 'further', 'from', 'd', 'herself', 'myself', 'their', 'me', 'during', 'over', 'all', 'not', 'for', 'than', 'itself', 'she', 'both', 'has', 'it', "you've", 'shouldn', 'out', 'yours', 'because', 'doing', 'needn', 'up', 'am', 'very', 'who', 'do', 'these', 'each', 'ours', 'nor', 'your', 'some', 'themselves', 'when', 'her', 'hasn', "isn't", "aren't"}
"""

# your text could be not about vegatables
your_text = "Eat a lot of your plate of kale."

# tokenize
# https://www.nltk.org/howto/tokenize.html#regression-tests-nltkwordtokenizer
your_tokenized_text = word_tokenize(your_text)
print(your_tokenized_text)
"""
['Eat', 'a', 'lot', 'of', 'your', 'plate', 'of', 'kale', '.'] 
"""

# filter
your_filtered_text = [w for w in your_tokenized_text if w not in stop_words]

print(your_filtered_text)
"""
['Eat', 'lot', 'plate', 'kale', '.']
"""

# join with a space
string_form = " ".join(your_filtered_text)
print(string_form)

"""
'Eat lot plate kale .'
"""

Just the code

Python
import nltk
from nltk.corpus import stopwords
from nltk.tokenize import sent_tokenize, word_tokenize


nltk.download('stopwords')
stop_words = set(stopwords.words('english'))

your_text = "Eat a lot of your plate of kale."
your_tokenized_text = word_tokenize(your_text)
your_filtered_text = [w for w in your_tokenized_text if w not in stop_words]
string_form = " ".join(your_filtered_text)