Skip to main content

Python library for working with emojis in Swahili

Project description

emojiswahili

Emojiswahili is a Python library for working with emojis in Swahili.

Features

  • Supports Swahili translations for Unicode emojis.
  • Converts text with Swahili emoji codes (e.g., :nishani_ya_dhababu:) to Unicode emojis (e.g., 🥇).
  • Converts Unicode emojis back to Swahili emoji codes.
  • Lists all emojis in a string (with their positions), e.g., emoji_list().
  • Extracts distinct emojis in a string, e.g., distinct_emoji_list().
  • Counts emojis in a string (optionally only unique ones), e.g., emoji_count().
  • Checks if a string is purely emoji, e.g., purely_emoji().

Example Usage

Emojis defined by the Unicode consortium
can be easily used with Swahili translations.

>>> import emojiswahili

# Emojize a string
>>> print(emojiswahili.emojize('Mshindi wakwanza anapata :nishani_ya_dhababu:'))
Mshindi wakwanza anapata 🥇

# Demojize a string
>>> print(emojiswahili.demojize('Mshindi wakwanza anapata 🥇'))
Mshindi wakwanza anapata :nishani_ya_dhababu:

# List all emojis (with positions) in a string
>>> text = "Hii ni 🥇 na 🥈"
>>> emoji_positions = emojiswahili.emoji_list(text)
>>> print(emoji_positions)
[{'match_start': 7, 'match_end': 8, 'emoji': '🥇'},
 {'match_start': 12, 'match_end': 13, 'emoji': '🥈'}]

# Get a list of distinct emojis
>>> print(emojiswahili.distinct_emoji_list(text))
['🥇', '🥈']

# Count emojis in a string
>>> print(emojiswahili.emoji_count(text))
2
>>> print(emojiswahili.emoji_count(text, unique=True))
2

# Check if a string is purely emoji
>>> print(emojiswahili.purely_emoji('🥇🥈'))
True
>>> print(emojiswahili.purely_emoji('Hii ni 🥇 na 🥈'))
False

Installation

Install via pip:

$ python -m pip install emojiswahili --upgrade

Development Guide

Code Style Check

Ensure the code adheres to style guidelines using ruff:

$ python -m pip install ruff
$ ruff check emojiswahili

Type Checking

Test the type hints using pyright or mypy:

$ python -m pip install pyright mypy typeguard
$ pyright emojiswahili
$ pyright tests
$ mypy emojiswahili
$ pytest --typeguard-packages=emojiswahili

Emoji Lists

Swahili Emoji List

You can find the complete Swahili emoji list at:


Authors and Maintainers

This project is developed and maintained by the eGARIDC Team / @ega

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

emojiswahili-1.0.2.tar.gz (51.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

emojiswahili-1.0.2-py3-none-any.whl (48.0 kB view details)

Uploaded Python 3

File details

Details for the file emojiswahili-1.0.2.tar.gz.

File metadata

  • Download URL: emojiswahili-1.0.2.tar.gz
  • Upload date:
  • Size: 51.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for emojiswahili-1.0.2.tar.gz
Algorithm Hash digest
SHA256 88d3c423fbe8a782576724923acbce01fd155ef9b4c3c5eb950cba66ff050430
MD5 2e726ed24487738fed937cdf91d1fdbc
BLAKE2b-256 3c4971dc36103626bf63d160df5a99312336bfb168e4773f145b4e782ab5ba7f

See more details on using hashes here.

File details

Details for the file emojiswahili-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: emojiswahili-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 48.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for emojiswahili-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 523beec8ff18ad8104aaa5d7c72116101eaca73d003a98485a0c7b64c9096c34
MD5 eab6dc01aefd5986538ea8681a0a7b40
BLAKE2b-256 35b119c0c4d463346a8a92c6c8805e2f30a6ddf56fad470c4d2380b7b3f91ec8

See more details on using hashes here.

Supported by

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