Created
December 28, 2019 16:10
-
-
Save GeorgeSeif/0ee1744c0d952ae164f8dd28e1ca5715 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nltk | |
from nltk.corpus import stopwords | |
sentence = "This is a sentence for removing stop words" | |
tokens = nltk.word_tokenize(sentence) | |
stop_words = stopwords.words('english') | |
filtered_tokens = [w for w in tokens if w not in stop_words] | |
print(filtered_tokens) | |
# Prints out ['This', 'sentence', 'removing', 'stop', 'words'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment