Created
June 24, 2019 05:53
-
-
Save ayushoriginal/6e96470e4ba06c24f91e56ae5097e723 to your computer and use it in GitHub Desktop.
remove noise and stopwords
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
def remove_stopwords(self): | |
from nltk.corpus import stopwords | |
import re | |
stop = set(stopwords.words("english")) | |
noise = ['user'] | |
for i,tweet in tqdm(enumerate(self.data),'Stopwords Removal'): | |
self.data[i] = [w for w in tweet if w not in stop and not re.match(r"[^a-zA-Z\d\s]+", w) and w not in noise] | |
return self.data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment