emoji-extractor

Extract, detect and count emoji


License
MIT
Install
pip install emoji-extractor==1.0.11

Documentation

Emoji extractor/counter

Installation

pip install emoji_extractor

Usage examples: see this Jupyter notebook

Info

It counts the emoji in a string, returning the emoji and their counts. That's it! It should properly detect and count all current multi-part emoji.

Details

  • Uses v15.1 of the current Full Emoji List.

  • possible_emoji.pkl is a pickled set of possible emoji, used to check for their presence in a string with a few additional characters like the exciting VARIATION-SELECTOR-16 and the individual characters which make up flag sequences.

  • big_regex.pkl is a pickled compiled regular expression. It's just 3777 regular expressions piped together in order of decreasing length. This is important to make sure that you can count multi-codepoint sequences like 'šŸ’šŸ½\u200dā™‚ļø' and so on.

  • Some emoji have a variation selector 0xFE0F, but some platforms strip these and still render the emoji form. However, the regex used here will capture both 'šŸ‘ļø\u200dšŸ—Øļø' (0xFE0F after each emoji codepoint) and 'šŸ‘\u200dšŸ—Ø' (no 0xFE0F) and even situations where some component codepoints can and do have variant selectors but others can but don't. See Unicode's Full Emoji List and search for '0xFE0F' to see which emoji this potentially affects.

Other work

If you want to do stuff more complicated than simply detecting, extracting and counting emoji then you might find this Python package useful.

To do

It may be possible to speed up the extraction/counting process by limited the regular expression used to only those which are possible, given the unique detected characters. I guess it would depend on how quickly the new smaller regex can be compiled. Storing them might be possible but the combinations are likely to be prohibitive.

Anything else

Feel free to email me about any of this stuff.