In [1]:
# Stop Words: Words that are of little value in the sentence and 
# removing which still keeps the meaning of the sentence intact.

from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize

text = "This is an example to show that how stop words is used in NLP!! Hope you like it."

words = word_tokenize(text)
stop_words = set(stopwords.words("english"))

print('English Stop Words: ',stop_words)
print('\n')

new_sent = []

for word in words:
    if word not in stop_words:
        new_sent.append(word)
print(new_sent)

print('\n')

arr = [word for word in words if word not in stop_words]
print(arr)


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


['This', 'example', 'show', 'stop', 'words', 'used', 'NLP', '!', '!', 'Hope', 'like', '.']


['This', 'example', 'show', 'stop', 'words', 'used', 'NLP', '!', '!', 'Hope', 'like', '.']

In [ ]: