Created
August 3, 2020 12:55
-
-
Save sid321axn/bf22950e71e204af401623807d706187 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from nltk.corpus import stopwords | |
stop = set(stopwords.words('english')) | |
punctuation = list(string.punctuation) | |
stop.update(punctuation) | |
# Removing stop words which are unneccesary from headline news | |
def remove_stopwords(text): | |
final_text = [] | |
for i in text.split(): | |
if i.strip().lower() not in stop: | |
final_text.append(i.strip()) | |
return " ".join(final_text) | |
df['title']=df['title'].apply(remove_stopwords) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment