Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import nltk
from nltk.corpus import stopwords
text = "Hi, Laptops from Hewlett-Packard aren't running MacOS. We would love an Apple Mac for our work."
print('Word tokenization - ')
word_token = nltk.word_tokenize(text)
print('\nSentence tokenization - ')
print('Word tokens after removing stopwords - ')
stop = set(stopwords.words('english'))
ans = [token for token in word_token if token not in stop]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment