Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

Markov name/word generator (RPG name generator).

Project description


Markov chain generator for random words.

Generates new words based on chains in the existing data. For example if input is cat, dat, drape. When a new word is generated it can start with c (33%) or d (67%). (There are two ds). If a d, the next letter is a (50%) or r (50%). Assuming it's an a, the next letter must be either p (3%3) or t (67%).

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)

Now call generate

>>> [word_factory.generate() for _ in range(5)]
['juzace', 'hexsene', 'varysarel', 'keynena', 'leely']

There's some default data which you can use. get_modes returns 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).

From Console

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.

Project details

Release history Release notifications

This version
History Node


History Node


History Node


History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
markovwordgen-0.9.9.tar.gz (6.7 kB) Copy SHA256 hash SHA256 Source None May 17, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page