Swahili Emoji for Python
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file emojiswahili-1.0.0.tar.gz.
File metadata
- Download URL: emojiswahili-1.0.0.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26b52e2e0c0d7e66a77ac8d6c841c37817b09bb51ecea64747552e90933cddb3
|
|
| MD5 |
f306af6959307f53222e65cfeb83575a
|
|
| BLAKE2b-256 |
efc8527580e0249c4737f5f6fcad845f8f594211eff053055e594b333d9489ef
|
File details
Details for the file emojiswahili-1.0.0-py3-none-any.whl.
File metadata
- Download URL: emojiswahili-1.0.0-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5933734f6cf212dcbb0b85fac3a51697077ac1c015fe6c57d64c9914f42cae0f
|
|
| MD5 |
d639466dba85fb993d9c20a87cecfc30
|
|
| BLAKE2b-256 |
c16c413035d22c67132b457f0cf5bc33053ba2516461310345d5696ccd233181
|