Coder Social home page Coder Social logo

kolanich-libs / emojinorm.py Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 11 KB

A library to normalize Unicode emoji sequencies

License: The Unlicense

Python 100.00%
emoji normalization icu unicode zero-width-character emoji-representation zero-width-joiner

emojinorm.py's Introduction

emojiNorm.py Unlicensed work

wheel (GHA via nightly.link) GitHub Actions Libraries.io Status Code style: antiflash

We have moved to https://codeberg.org/KOLANICH-libs/emojiNorm.py, grab new versions there.

Under the disguise of "better security" Micro$oft-owned GitHub has discriminated users of 1FA passwords while having commercial interest in success and wide adoption of FIDO 1FA specifications and Windows Hello implementation which it promotes as a replacement for passwords. It will result in dire consequencies and is competely inacceptable, read why.

If you don't want to participate in harming yourself, it is recommended to follow the lead and migrate somewhere away of GitHub and Micro$oft. Here is the list of alternatives and rationales to do it. If they delete the discussion, there are certain well-known places where you can get a copy of it. Read why you should also leave GitHub.


A library to normalize Unicode emoji sequencies. Currently broken for some cases, needs more fixing and testing. Use with care.

Usage

normalizeEmoji

Does emoji normalization

  • remove redundant zero-width-joiners;
  • add missing zero-width joiners;
  • add emoji presentation selectors where they are needed.
normalizeEmoji('☑') # ☑️

Issues:

  • some compound emoji (i.e. "👩🏿\u200d❤\ufe0f\ufe0f\u200d👨🏻") contain a sequence of 2 presentation selectors right after each other (\ufe0f\ufe0f). This function breaks those emoji since it first strips all emoji presentation selectors, and then generates them from scratch. It seems that for those emoji the only way is to remember that they are constructed this way. Currently I'm not sure how to handle them, so they are broken.

graphemeCount

Counts graphemes. Emoji must contain of 1.

o = '🚴️♂'
print(graphemeCount(o))  # 2
r = normalizeEmoji(o)
print(r, graphemeCount(r))  # 🚴‍♂️ 1

stripDiversity

Strips skin tone, hair style modifiers and gender (not all, only deity-based (Venus/Mars)) zwj seqs.

print(*stripDiversity("👩🏻‍❤︎️‍👨🏿"))  # 👩‍❤︎‍👨 {'skin': ('🏻', '🏿')}
print(*stripDiversity("👩🏻‍🦰"))  # 👩 {'hair': ('🦰',), 'skin': ('🏻',)}
print(*stripDiversity("🚵‍♂️"))  # 🚵 {'genderDeity': ('♂',)}

stripDiversityPerson

Replaces man/woman code points with person ones.

print(*stripDiversityPerson("👨‍🚒"))  # 🧑‍🚒 {'genderPerson': ('👨',)} (male firefighter to just firefighter)

emojinorm.py's People

Contributors

kolanich avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.