Markov name/word generator (RPG name generator).
Markov chain generator for random words.
Generates new words based on chains in the existing data. For example if
cat, dat, drape. When a new word is generated it can start
c (33%) or
d (67%). (There are two ds). If a
d, the next
a (50%) or
r (50%). Assuming it's an
a, the next letter
must be either
p (3%3) or
Letter pairs that can start and end a word are special-cased.
As a Python Library
Create an isntance of the generator and prime with a list of strings or a file object containing the same.
>>> from markovwordgen import MarkovWordGen >>> mydata = ['aimee', 'alexandra', 'alice' ... ] >>> word_factory = MarkovWordgen(mydata)
>>> [word_factory.generate() for _ in range(5)] ['juzace', 'hexsene', 'varysarel', 'keynena', 'leely']
There's some default data which you can use.
a dictionary of them.
>>> import markovwordgen >>> markovwordgen.get_modes()
If no data supplied it, will default to some elf-like names with too many vowels (the relf set in the list above).
As a console app use
--help for CLI docs. There's some default
data in there.
$ mwgen --help
The generator special cases starting and ending letter pairs, so it's OK if your input data is capitalized.
Are your results bad? Make sure you have a sufficiently long input file. 50 words should do it.
You might need to filter output, e.g. remove quadruple letters and capitalize it.