Add support for Multi-person skintones #259
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Finally finished this. It looks like quite a lot of changes, but apart from the multi-person skintones, I mostly just moved code around and deleted unused code:
The logic from
demojize()
is moved to two separate private functiontokenize()
andfilter_tokens()
in a new fileemoji/tokenizer.py
demojize()
,replace_emoji()
,emoji_list()
andanalyze()
all use the same logic, that's why I moved it into the new private functiontokenize()
andfilter_tokens()
. Otherwise there would have been duplicated code.Also the logic for the search tree is moved to the
emoji/tokenizer.py
file.A new public function
analyze()
is available and that supports the multi-person skintones. It's similar toemoji_list()
. It returnsToken
andEmojiMatch
objects that provide more information thanemoji_list()
and also allow to split up ZWJ-emoji into the sub-emoji.The handling of the multi-person skintones in
demojize()
andreplace_emoji
can be controlled by the newemoji.config
class, which is a static class that works as a module-wide configuration:I have removed support for Python 2, 3.4, 3.5, because I used some features of Python 3.6. I removed lots of things that were specific to Python 2, especially all the
u'strings'
.Fixes #204
Fixes #256