Crates.io | namegen |
lib.rs | namegen |
version | 0.1.4 |
source | src |
created_at | 2021-02-23 19:01:03.13239 |
updated_at | 2023-04-25 15:22:59.107387 |
description | Fast name generator. |
homepage | |
repository | |
max_upload_size | |
id | 359599 |
size | 88,415 |
namegen
This library offers high performance random name generation with sub-microsecond full names on even older computers. My use case for this is a website, but I've left this general enough to even fit into other procedural generation systems.
serde
support with feature flag serde
wasm_bindgen
supported. The github repo has a project for building it.The name formats has a special syntax. They're what describes how to build a full name from the parts. The tokens are in curly braces, and they mean the following.
{first_name}
: Generate part with name first_name
.{=stuff}
: Returns the word "stuff".{first_name|=Unnamed}
: A |
indicates a random pick between the items. Here it will either generate the first_name
part or just the word Unnamed.{:full_name}
: The :
prefix denotes a format. It can only refer to formats that were added before it, both due to
optimization and to avoid an infinite recursion.Here are a few examples.
{first_name} {last_name}
: The referred name parts with a space between.{first}'{clan} {=vas|=nar} {ship}
: The third {...}
is either one of these two.{:full_name|:first_name}, the {title}
: The first {...}
chooses between these two formats.markov
Generate names using a second-order markov chain. This is not a naive implementation, however, and some constraints has been made to create more faithful names:
cfgrammar
Generate names using a context-free grammar, with some constraints to keep symbol frequencies in check and to deal with
those damn y
s.
wordlist
A simple word list generator, for the cases where output should be one of the samples. The samples can be weighted.