Code Monkey home page Code Monkey logo

emoji_skintones's Introduction

Emoji Skin Tone

Emoji Skin Tone is a Python library that allows you to manipulate the skin tones of human emojis in a string. It provides functionality to strip skin tone modifiers from emojis, extract human emojis from a string, and apply a specific skin tone to human emojis.

Features

  • Strip Skin Tone Modifiers: Remove all skin tone modifiers from human emojis in a string.
  • Extract Human Emojis: Extract all human emojis from a string, including any present skin tone modifiers.
  • Apply Skin Tone: Apply a specific skin tone to all human emojis in a string.

Installation

You can install this library locally by downloading this repository and using pip:

pip install emoji-skin-tone

The Fitzpatrick Scale

The Fitzpatrick scale is a six-point classification system for human skin color. Emoji characters can be modified to use one of five different skin tone modifiers. Each tone is based on the Fitzpatrick Scale.

The Fitzpatrick enum in the emoji_skin_tone module represents the five different skin tone modifiers:

  • Fitzpatrick.type_1_2: Light skin (e.g. ๐Ÿ‘ฉ๐Ÿป)
  • Fitzpatrick.type_3: Medium-Light skin (e.g. ๐Ÿ‘ฉ๐Ÿผ)
  • Fitzpatrick.type_4: Medium skin (e.g. ๐Ÿ‘ฉ๐Ÿฝ)
  • Fitzpatrick.type_5: Medium-Dark skin (e.g. ๐Ÿ‘ฉ๐Ÿพ)
  • Fitzpatrick.type_6: Dark skin (e.g. ๐Ÿ‘ฉ๐Ÿฟ)

You can use these types with the apply_skin_tone function to apply skin tone modifiers to human emojis in a string.

Usage

This library provides a set of functions for manipulating emoji skin tones in a string. Here's how you can use them:

from emoji_skin_tone import Fitzpatrick, strip_skin_tone_modifiers, extract_human_emoji, apply_skin_tone

# To strip skin-tone modifiers from a string:
stripped_string = strip_skin_tone_modifiers("Hello World! ๐Ÿ‘ฉ๐Ÿฝโ€๐Ÿ’ป๐Ÿ‘จ๐Ÿฟโ€๐Ÿ’ป")
# The output will be: "Hello World! ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป"

# To extract human emojis from a string:
emoji_list = extract_human_emoji("Hello World! ๐Ÿ‘ฉ๐Ÿฝโ€๐Ÿ’ป๐Ÿ‘จ๐Ÿฟโ€๐Ÿ’ป")
# The output will be: ['๐Ÿ‘ฉ๐Ÿฝโ€๐Ÿ’ป', '๐Ÿ‘จ๐Ÿฟโ€๐Ÿ’ป']

# To apply skin-tone modifiers to human emojis in a string:
colored_string = apply_skin_tone("Hello World! ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป", Fitzpatrick.type_4)
# The output will be: "Hello World! ๐Ÿ‘ฉ๐Ÿฝโ€๐Ÿ’ป๐Ÿ‘จ๐Ÿฝโ€๐Ÿ’ป"

CLI Usage

The library also provides a command-line interface for these functions:

  • To strip skin-tone modifiers from a string:
    python cli.py strip "Hello World! ๐Ÿ‘ฉ๐Ÿฝโ€๐Ÿ’ป๐Ÿ‘จ๐Ÿฟโ€๐Ÿ’ป"
  • To extract human emoji from a string:
    python cli.py extract "Hello World! ๐Ÿ‘ฉ๐Ÿฝโ€๐Ÿ’ป๐Ÿ‘จ๐Ÿฟโ€๐Ÿ’ป"
  • To apply skin-tone modifiers to human emoji in a string:
    python cli.py apply "Hello World! ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป" 4

Unit Tests

This library includes a comprehensive set of unit tests to ensure the correctness of its main features. The tests cover various scenarios and verify the behavior of the functions provided by the library.

To run the unit tests, follow these steps:

  1. Ensure you have Python installed on your machine.

  2. Navigate to the root directory of the project where the test_emoji_skin_tone.py file is located.

  3. Run the following command to execute the unit tests:

    python test_emoji_skin_tone.py

    This will run all the tests and display the results in the console.

The unit tests validate the functionality of the following functions:

  • strip_skin_tone_modifiers: Tests the removal of skin tone modifiers from a string.
  • extract_human_emoji: Tests the extraction of human emojis from a string.
  • apply_skin_tone: Tests the application of skin tone modifiers to human emojis in a string.

Running the unit tests and observing that all tests pass confirms that the library's core features are working as intended. If any tests fail, it indicates a potential issue that needs investigation.

Feel free to explore the test_emoji_skin_tone.py file to see the specific test cases and assertions used in the unit tests.

emoji_skintones's People

Contributors

kimo26 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.