Skip to content

Instantly share code, notes, and snippets.

@Abhayparashar31
Last active October 27, 2022 03:31
Show Gist options
  • Save Abhayparashar31/63a0c3270007ceeb9496cdb0249e2983 to your computer and use it in GitHub Desktop.
Save Abhayparashar31/63a0c3270007ceeb9496cdb0249e2983 to your computer and use it in GitHub Desktop.
import nltk
nltk.download('stopwords')
from nltk.corpus import stopwords
english_stopwords = set(stopwords.words('english'))
corpus = ['Food is Bad',
'Bad Service Bad Food',
'Food is Good',
'Good Service With Good Food.',
'Service is Bad but Food is Good.']
cleaned_corpus = []
for sent in corpus:
sent = sent.lower()
cleaned_corpus.append(' '.join([word for word in sent.split() if word not in english_stopwords]))
print(cleaned_corpus)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment