Created
October 12, 2022 17:05
-
-
Save yavuzKomecoglu/87fb8b0bc7c8b8b377a3d56b885a99fe 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
def handle_emojis(tweet): | |
# Smile -- :), : ), :-), (:, ( :, (-:, :') | |
tweet = re.sub(r'(:\s?\)|:-\)|\(\s?:|\(-:|:\'\))', ' EMO_POS ', tweet) | |
# Laugh -- :D, : D, :-D, xD, x-D, XD, X-D | |
tweet = re.sub(r'(:\s?D|:-D|x-?D|X-?D)', ' EMO_POS ', tweet) | |
# Love -- <3, :* | |
tweet = re.sub(r'(<3|:\*)', ' EMO_POS ', tweet) | |
# Wink -- ;-), ;), ;-D, ;D, (;, (-; | |
tweet = re.sub(r'(;-?\)|;-?D|\(-?;)|😉', ' EMO_POS ', tweet) | |
# Sad -- :-(, : (, :(, ):, )-: | |
tweet = re.sub(r'(:\s?\(|:-\(|\)\s?:|\)-:)', ' EMO_NEG ', tweet) | |
# Cry -- :,(, :'(, :"( | |
tweet = re.sub(r'(:,\(|:\'\(|:"\()', ' EMO_NEG ', tweet) | |
return tweet | |
def remove_emoji(string): | |
emoji_pattern = re.compile("[" | |
u"\U0001F600-\U0001F64F" # emoticons | |
u"\U0001F300-\U0001F5FF" # symbols & pictographs | |
u"\U0001F680-\U0001F6FF" # transport & map symbols | |
u"\U0001F1E0-\U0001F1FF" # flags (iOS) | |
u"\U00002500-\U00002BEF" # chinese char | |
u"\U00002702-\U000027B0" | |
u"\U00002702-\U000027B0" | |
u"\U000024C2-\U0001F251" | |
u"\U0001f926-\U0001f937" | |
u"\U00010000-\U0010ffff" | |
u"\u2640-\u2642" | |
u"\u2600-\u2B55" | |
u"\u200d" | |
u"\u23cf" | |
u"\u23e9" | |
u"\u231a" | |
u"\ufe0f" # dingbats | |
u"\u3030" | |
"]+", flags=re.UNICODE) | |
return emoji_pattern.sub(r'', string) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment