Error in google colab(python) while transliterating data into Indian language

May 2024 ยท 1 minute read

I am transliterating data into India language using python in google colab, but encountered error: AttributeError: module 'emoji' has no attribute 'UNICODE_EMOJI'

The error occurs to the second line in the code:

for word in line_list: if word in emoji.UNICODE_EMOJI: new_line_list.append(emoji.demojize(word)) 

emoji package in installed and imported version is 2.0.0

3 Answers

You can use the function distinct_emoji_list() to extract emojis in a string and return a list of found emojis, then call emoji.demojize() on each emoji in that list to convert it into its meaning.

so having:

line_list = ['Hello World! ๐Ÿ˜„', 'Goodbye World ๐Ÿ˜…'] new_line_list = [] for word in line_list: emojis = emoji.distinct_emoji_list(word) new_line_list.extend([emoji.demojize(is_emoji) for is_emoji in emojis]) 

Printing new_line_list would give

[':grinning_face_with_smiling_eyes:', ':grinning_face_with_sweat:'] 

latest version of emoji==2.1.0 has no attribute Unicode_emoji. So, try to uninstall the existing version and install emoji==1.7.0

1

I found this emoji.UNICODE_EMOJI and emoji.UNICODE_EMOJI['en] as an error.
So, I got it solved using emoji.distinct_emoji_list(test)
where, test is a string.
cheers!

ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJobmxoYmmGeIKOnqmrp6Jitq95xqimoKSVYrCwuMCbp7KsmKS7bsPHoqOeZaSnrq%2B%2Fy6KrnqqRqbavs4ydmK2ZXZ67tbuMoqWdoZGjeq2tzaCsmp%2BV