Last active
August 7, 2019 02:27
-
-
Save mohdsanadzakirizvi/4bba4525166d44aaca640cb874a14e21 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
long_words=[] | |
# remove short word | |
for i in newString.split(): | |
if len(i)>=3: | |
long_words.append(i) | |
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