Skip to content

Instantly share code, notes, and snippets.

Embed
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(word_token)
print('\nSentence tokenization - ')
print(nltk.sent_tokenize(text))
print('Word tokens after removing stopwords - ')
stop = set(stopwords.words('english'))
ans = [token for token in word_token if token not in stop]
print(ans)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.