-
-
Save BernardOng/2a9ea6ba8c842b55e0c63d67dc759109 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
def cleanupTitle(self, s): | |
# remove stopwords | |
stopset = set(stopwords.words('english')) | |
punctuations = list(string.punctuation) | |
tokens = [i for i in nltk.word_tokenize(re.sub(r'\d+', '', s.lower())) if i not in punctuations] | |
cleanup = " ".join(filter(lambda word: word not in stopset, tokens)) | |
cleanup = self.remove_non_ascii(cleanup) | |
cleanup = cleanup.replace('...','') | |
cleanup = cleanup.replace("'s",'') | |
cleanup = cleanup.replace("''",'') | |
cleanup = cleanup.replace("``",'') | |
cleanup = cleanup.replace("-",'') | |
cleanup = cleanup.replace("''",'') | |
cleanup = cleanup.replace("'",'') | |
return cleanup | |
def cleanTokens(self, s): | |
return nltk.word_tokenize(self.cleanupTitle(s)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment