Skip to content

Instantly share code, notes, and snippets.

@prateekjoshi565
Created April 21, 2019 12:11
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