How to identify same emoji with different colours?
Example: šš» šš½ š the should be considered as being the same
Edit: Currently I am using emoji package
import regex
import emoji
exm = "poli kariku fans adi like šš» šš½ š sub tharamo"
characters = regex.findall("\X",exm)
for char in character:
if char in emoji.UNICODE_EMOJI:
#do something
I don't think you need to use regex for your use case you can just use the length of the emoji:
import emoji
NUM_COLUMNS = 4
TABLE_COLUMN_WIDTH = 18
def is_emoji(s):
return s in emoji.UNICODE_EMOJI
def is_default_emoji(s):
return len(s) == 1 and s in emoji.UNICODE_EMOJI
def get_default_emoji(s):
return s[0] if s in emoji.UNICODE_EMOJI else None
def pretty_print_line(line):
print(''.join(word.ljust(TABLE_COLUMN_WIDTH) for word in line.split()))
text = "poli kariku fans adi like šš» šš¼ šš½ šš¾ ššæ š sub tharamo"
pretty_print_line("string is_emoji is_default_emoji get_default_emoji")
print("=" * NUM_COLUMNS * TABLE_COLUMN_WIDTH)
for s in text.split():
pretty_print_line(f'{s} {is_emoji(s)} {is_default_emoji(s)} {get_default_emoji(s)}')
Output:
string is_emoji is_default_emoji get_default_emoji
========================================================================
poli False False None
kariku False False None
fans False False None
adi False False None
like False False None
šš» True False š
šš¼ True False š
šš½ True False š
šš¾ True False š
ššæ True False š
š True True š
sub False False None
tharamo False False None
You could use some logic similar to get_default_emoji
for your use case since it returns the same emoji regardless of the presence or lack of presence of a skin tone modifier.