Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to identify same emoji of different colors/skin tone in python?

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
like image 954
raviTeja Avatar asked Dec 11 '22 00:12

raviTeja


1 Answers

There is no method available on the emoji package to treat same symbols with different colors similar. However, we can achieve this by comparing the emoji names with the common string (Here it is thumbs_up)

Try the below code.

import regex
import emoji
exm = "poli kariku fans adi like 👍🏻 👍🏽 👍 sub tharamo"
characters = regex.findall("\X",exm)
for char in characters:
  if char in emoji.UNICODE_EMOJI:
      if "thumbs_up" in (emoji.demojize(char)):
          print("It is thumbs_up")

For the list of emojis supported and their names refer to the source code here.

like image 80
Mithilesh_Kunal Avatar answered Dec 28 '22 16:12

Mithilesh_Kunal