Skip to main content

emoji-data from Unicode® Emoji

Project description

emoji-data

CircleCI Codacy Badge Documentation Status


A library represents emoji sequences and characters from the data files listed in Unicode® Technical Standard #51(UNICODE EMOJI)

How to use

Examples below also in a notebook

Class EmojiSequence is most useful:

from emoji_data import EmojiSequence

EmojiSequence.initial()

initial() MUST be called - it loads emoji data files into the class' meta data

Iterate print Emojis

>>> for s, es in EmojiSequence:
>>>    print(' '.join('{:02X}'.format(n) for n in es.codes), s)

231A 
231B 
23E9 
23EA 
23EB 
23EC 
23F0 
23F3 
# ...
1F469 1F3FE 200D 1F33E 👩🏾‍🌾
1F469 1F3FE 200D 1F373 👩🏾‍🍳
1F469 1F3FE 200D 1F393 👩🏾‍🎓
1F469 1F3FE 200D 1F3A4 👩🏾‍🎤
1F469 1F3FE 200D 1F3A8 👩🏾‍🎨
1F469 1F3FE 200D 1F3EB 👩🏾‍🏫
1F469 1F3FE 200D 1F3ED 👩🏾‍🏭
1F469 1F3FE 200D 1F4BB 👩🏾‍💻
1F469 1F3FE 200D 1F4BC 👩🏾‍💼
1F469 1F3FE 200D 1F527 👩🏾‍🔧
1F469 1F3FE 200D 1F52C 👩🏾‍🔬
1F469 1F3FE 200D 1F680 👩🏾‍🚀
1F469 1F3FE 200D 1F692 👩🏾‍🚒
# ...

Check if hex list represents an Emoji

>>> hexes_list = [
        '1F6A3',
        '1F468 1F3FC 200D F68F',
        '1F468 1F3FB 200D 2708 FE0F',
        '023A',
        '1F469 200D 1F52C',
        '1F468 200D 1F468 200D 1F467 200D 1F467',
        '1F441 FE0F 200D 1F5E8 FE0E'
    ]

>>> for hexes in hexes_list:
>>>     try:
>>>         es = EmojiSequence.from_hexes(hexes.split())
>>>     except KeyError:
>>>         print('{} is NOT Emoji!'.format(hexes))
>>>     else:
>>>         print('{} is Emoji {}'.format(hexes, es.string))

1F6A3 is Emoji 🚣
1F468 1F3FC 200D F68F is NOT Emoji!
1F468 1F3FB 200D 2708 FE0F is Emoji 👨🏻‍✈️
023A is NOT Emoji!
1F469 200D 1F52C is Emoji 👩‍🔬
1F468 200D 1F468 200D 1F467 200D 1F467 is Emoji 👨‍👨‍👧‍👧
1F441 FE0F 200D 1F5E8 FE0E is NOT Emoji!

Check if a string is Emoji

>>> print('👨' in EmojiSequence)
>>> print('©' in EmojiSequence) # 00AE, unqualified
>>> print('5️⃣' in EmojiSequence)
>>> print('9⃣' in EmojiSequence)  # 0039 20E3, unqualified

True
False
True
False

Search Emojis inside texts

>>> pat = EmojiSequence.pattern

>>> strings = [
        "First:👨🏻‍⚕️. Second:👨🏻.",
        "I love 👨‍👨‍👧‍👧. It's ⛈️. I am 😀."
    ]

>>> for s in strings:
>>>     m = pat.search(s)
>>>     while m:
>>>         print('matched: [{} : {}] : {}'.format(m.start(), m.end(), m.group()))
>>>         m = pat.search(s, m.end())
>>>     print()

matched: [6 : 11] : 👨🏻‍⚕️
matched: [20 : 22] : 👨🏻

matched: [7 : 14] : 👨‍👨‍👧‍👧
matched: [21 : 23] : ⛈️
matched: [30 : 31] : 😀

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

emoji-data-0.1.3.tar.gz (138.1 kB view hashes)

Uploaded Source

Built Distribution

emoji_data-0.1.3-py3-none-any.whl (110.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page