Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# 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