Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import re
def text_cleaner(text):
# lower case text
newString = text.lower()
newString = re.sub(r"'s\b","",newString)
# remove punctuations
newString = re.sub("[^a-zA-Z]", " ", newString)
# remove short word
for i in newString.split():
if len(i)>=3:
return (" ".join(long_words)).strip()
# preprocess the text
data_new = text_cleaner(data_text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment