INNER CODE UNIT · Python
preprocess
graviraja/100-Days-of-NLP · applications/classification/toxic_comment_classification/app/app.py:26
def preprocess(text):
# -- Converting to lower case
text = text.lower()
# replacing english abbreviations with full forms
text = re.sub(r"what's", "what is ", text)
text = re.sub(r"\'s", " ", text)
text = re.sub(r"\'ve", " have ", text)
text = re.sub(r"can't", "can not ", text)
text = re.sub(r"n't", " not ", text)
text = re.sub(r"i'm", "i am ", text)
text = re.sub(r"\'re", " are ", text)
text = re.sub(r"\'d", " would ", text)
text = re.sub(r"\'ll", " will ", text)
text = re.sub(r"\'scuse", " excuse ", text)
# text = re.sub('\W', ' ', text)
# text = re.sub('\s+', ' ', text)