1from nltk.corpus import stopwords
2from nltk.tokenize import word_tokenize
3
4example_sent = """This is a sample sentence,
5 showing off the stop words filtration."""
6
7stop_words = set(stopwords.words('english'))
8
9word_tokens = word_tokenize(example_sent)
10
11filtered_sentence = [w for w in word_tokens if not w.lower() in stop_words]
1traindf['title'] = traindf['title'].apply(lambda x: ' '.join([word for word in x.lower().split() if word not in
2 stopwords.words('english') and string.punctuation]))