Published on 2023-09-16 by GCH

Fake dictionary entries

After a number of serious posts, I realized this blog needed a silly season. So here it is.

Recently, I wanted to create a fake dictionary entry for a presentation slide but wasn't sure how to achieve a good looking layout. I looked up a generator website but Google is having a hard time with all the SEO bombs it allows for, so I couldn't manage to find a trustworthy generator in a timely manner (2 minutes).

It seemed as if I'd have to understand the layout based on whatever images I could find and then reproduce it by hand with point and click. No drama. Then I thought: there is probably an easy way to layout text over an image so that I don't have to do it manually if I ever need it again.

In the spirit of XKCD automation, the initial presentation slide lost some of its importance, compared to the fun of programatically generating fake dictionary entries. Turns out that with with Python PIL it isn't terribly complicated to combine text and images over a PNG. And I made a silly script, called definitive, to make it even easier.

In order to get started you just need to prepare your Ubuntu based environment,

sudo apt update
sudo apt install python3-matplotlib fonts-freefont-ttf
git clone https://github.com/ghomem/definitive.git
cd definitive

and then you're ready to produce definition cards.

Definitive comes with 3 built-in avatars to complement the definition text: Grug, Normand and Troll. They can be selected with the -a parameter. For instance, if you wanted to produce the definition of definition using the beautiful Grug avatar you could simply run,

DEFINITION='a statement of the meaning of a word or word group or a sign or symbol'
OUTPUT_FILE="/tmp/my-definition2.png"
python3 definitive.py -w definition -c noun -d "$DEFINITION" -s definition -a grug -dh -o "$OUTPUT_FILE"

and get the following result:

If the -a parameter is not used, no avatar will be added to the definition card. Font color and background color can be defined in hex format and passed to the -bc and -fc parameters. Executing with -h provides the full set of self-explanatory options.

That's all very interesting, but given the role this blog plays as a relevant part of the mass media, we can't finish this post without a definition of silly season.

And that will be all for today.

Note: the definitions of definition and silly season are taken from the Merriam-Webster dictionary.