Skip to main content

Convert any word in the English language to an emoji

Project description

word2emoji

This simple module exposes one method to convert a single, english word to an emoji:

import word2emoji

print(word2emoji.lookup("beer"))

>>> 🍺

It works by way of a simple lookup table. You could use a pretrained model, but given that there are only a limited set of words in English it doesn't seem worth it. To build the look up table you need to run a number of steps:

Create the training set

The training.txt file contains a simple set to train on. test_to_training.py will convert it to training_prepared.jsonl which can be consumed by openai. Before you can get started, set your OPENAI_KEY:

export export OPENAI_API_KEY="sk-urshouldgohere"

You can then train fine tune the model. I use davinci:

openai api fine_tunes.create -t training_prepared.jsonl -m davinci

This will take a few minutes (it does require the )

Creating the lookup table

Now you are ready to create the lookup. This is done using

python create_db.py

Update the name of the model there if you want to use your own and delete/update words.json - this contains a dictionary from word-stem to (word, emoji) pair.

Once you are happy with your new db, you can run:

python flatten_db.py

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

word2emoji-0.1.4.tar.gz (661.1 kB view details)

Uploaded Source

Built Distribution

word2emoji-0.1.4-py3-none-any.whl (662.4 kB view details)

Uploaded Python 3

File details

Details for the file word2emoji-0.1.4.tar.gz.

File metadata

  • Download URL: word2emoji-0.1.4.tar.gz
  • Upload date:
  • Size: 661.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.8

File hashes

Hashes for word2emoji-0.1.4.tar.gz
Algorithm Hash digest
SHA256 3e810df5e1fb37987dc5e9349390fd07fb14fdda8fed577979b49a64f1cb4781
MD5 5674381d941a0a30661299f58e5cdbbe
BLAKE2b-256 f879a7f53cbb01ee2f1dc0540a553c682696d54b552bcbaa7a865f49bbf95570

See more details on using hashes here.

File details

Details for the file word2emoji-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: word2emoji-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 662.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.8

File hashes

Hashes for word2emoji-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d85593dc25bb4d67c1e5c9f5ccb8c700f3a5e34ae37e4c497680b0b52c4b8d9c
MD5 b19c2124407a7e7ed2347117a6fd56f2
BLAKE2b-256 c22fe2cb1372c23c46c486ef21c4a1b9cc49594cd5bb0168f95515a656d31cc6

See more details on using hashes here.

Supported by

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