Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save saimadhu-polamuri/a04fdee5d406ca20d3df9de40e60b36d to your computer and use it in GitHub Desktop.
Save saimadhu-polamuri/a04fdee5d406ca20d3df9de40e60b36d to your computer and use it in GitHub Desktop.
# Preprocess text
def preprocess_text(text):
# Remove stop words stop_words = set(stopwords.words("english"))
words = word_tokenize(text.lower())
filtered_words = [word for word in words if word not in stop_words]
return " ".join(filtered_words)
data["preprocessed_text"] = data["text"].apply(preprocess_text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment