donjon

#StandWithUkraine 🇺🇦

Support me on Patreon

Name Generator

How it Works

This name generator constructs and uses Markov chains. Given a list of sample names, it analyzes each name to construct frequency tables for name length and letter pairs. It then uses these tables to construct a new name in the style of the sample set.

Source Code

The following source code provides a JavaScript random name generator, and some example data. The name generator is released to the public domain. The example data is drawn from Kate Monk's Onomastikon, © 1997 Kate Monk.

Using the Generator

First, you'll need to create a JavaScript data file. This file defines an array list of sample names as a named element of the name_set object (which is declared in name_generator.js).

Then, include both the name_generator.js file and your data file in your HTML page. A clever person might note that you could easily create and include more than one data file here.

<script src="name_generator.js"></script>
<script src="egyptian_set.js"></script>

The generate_name() function accepts a single argument, the name of your name set, and returns a text string. You can simply write this text string to the HTML page...

<script type="text/javascript">
  document.write(generate_name('egyptian'));
</script>

Or assign it to a variable in your own JavaScript code. You may also be interested in the name_list() function, which accepts the name of a name set and a number, and returns an array of generated names.

tl;dr