Update utils.py

pull/134/head
Who? 2025-04-21 15:35:53 +07:00 committed by GitHub
parent 7622cf6680
commit bdca57fbf5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 0 deletions

View File

@ -46,6 +46,7 @@ import time
import typing import typing
from datetime import timedelta from datetime import timedelta
from urllib.parse import urlparse from urllib.parse import urlparse
import emoji
import git import git
import grapheme import grapheme
@ -1446,6 +1447,16 @@ def remove_html(text: str, escape: bool = False, keep_emojis: bool = False) -> s
) )
) )
def remove_emoji(text: str) -> str:
"""
Removes all emoji from text
"""
allchars = [str for str in text]
emoji_list = [c for c in allchars if c in emoji.EMOJI_DATA]
clean_text = ' '.join([str for str in text.split() if not any(i in str for i in emoji_list)])
return clean_text
def get_kwargs() -> typing.Dict[str, typing.Any]: def get_kwargs() -> typing.Dict[str, typing.Any]:
""" """