def clean_text(text): #remove emojis, remove links, anonymize user mentions clean = "" text = emojilib.replace_emoji(text, replacement=' ') text = re.sub( '\s+', ' ', text).strip() for t in text.split(" "): if t.startswith('http'): pass else: clean += t + " " #remove double spaces return clean
def clean_text(text): #remove emojis, remove links, anonymize user mentions clean = "" text = emojilib.replace_emoji(text, replacement=' ') text = re.sub( '\s+', ' ', text).strip() for t in text.split(" "): if t.startswith('@') and len(t) > 1: clean += "@user " elif t.startswith('http'): pass else: clean += t + " " #remove double spaces return clean