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

6.3k Views Asked by At

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

4

There are 4 best solutions below

0
Nehal On

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:']
0
Aminur Rahman Ashik On

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!

1
MOHAN KRISHNA LANDA On

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

0
Yuvraj On

In the latest version of emoji the property UNICODE_EMOJI has been removed in version 2.0.0.

You can try to use EMOJI_DATA as a replacement for UNICODE_EMOJI. If you explain how you use UNICODE_EMOJI.

You can also downgrade the module version to emoji~=1.6.3 and stay with the old version that has the UNICODE_EMOJI property.