Skip to content

Instantly share code, notes, and snippets.

@prateekjoshi565
Created April 21, 2019 12:11
Show Gist options
  • Save prateekjoshi565/3adef1a5cfe443a79515a2a9c5227215 to your computer and use it in GitHub Desktop.
Save prateekjoshi565/3adef1a5cfe443a79515a2a9c5227215 to your computer and use it in GitHub Desktop.
genre_text_cleaning
# function for text cleaning
def clean_text(text):
# remove backslash-apostrophe
text = re.sub("\'", "", text)
# remove everything except alphabets
text = re.sub("[^a-zA-Z]"," ",text)
# remove whitespaces
text = ' '.join(text.split())
# convert text to lowercase
text = text.lower()
return text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment