Skip to content

Instantly share code, notes, and snippets.

@himlohiya
Created June 29, 2018 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save himlohiya/28c27e963740b09b84fac03467f4efef to your computer and use it in GitHub Desktop.
Save himlohiya/28c27e963740b09b84fac03467f4efef to your computer and use it in GitHub Desktop.
def remove_stopwords(text, is_lower_case=False):
tokens = tokenizer.tokenize(text)
tokens = [token.strip() for token in tokens]
if is_lower_case:
filtered_tokens = [token for token in tokens if token not in stopword_list]
else:
filtered_tokens = [token for token in tokens if token.lower() not in stopword_list]
filtered_text = ' '.join(filtered_tokens)
return filtered_text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment