Generate an example "name"

TL;DR

Want a name for your initiative? Why not pair an adjective and a noun then? Why not generate it programatically?!?

In a couple of previous posts we looked at how to get our hands on some words - for example A Public Domain List of Words.

Let’s put that list to work:

Local version here. If you need it, you can also find the JSON file with words.

Reading the whole JSON file in a Perl data structure is encapsulated in its own function read_json in lines 27-31.

Function generate_pair is devoted to draw an adjective and a noun randomly:

  • for adjectives, we consider the direct ones with the addition of a couple of verbal forms, namely past participles and ing forms;
  • for nouns… we just use nouns.

After drawing them, the pair is returned as an anonymous array (line 24) and printed out (line 11).

Time for a sample run:

$ for x in 1 2 3 4 5 ; do ./generate-name.pl ; done
trotting moons
chopping scratches
good crews
lathering crevices
screamed cyclone

Funny 😄


Comments? Octodon, , GitHub, Reddit, or drop me a line!