Giter Site home page Giter Site logo

markov_names's Introduction

Markov Names

This is a simple little Markov-chain based name generator suitable for tabletop RPGs or procedural-content computer games.

Place your name source lists in the namedata/ folder. You can generate names based on each source list independently, for different cultural flavors. You can request a sequence of names from a sequence of source lists. Several source lists are provided.

Command Line Options

usage: names.py [-h] 
                [--count COUNT] 
                [--sequence] 
                [--star] 
                [--min MIN]
                [--max MAX]
                [--new]

optional arguments:
  -h, --help     show this help message and exit
  --count COUNT  number of names to generate
  --sequence     use name sets in order instead of randomly 
  --star         generate a star name in a fictional constellation
  --min MIN      minimum name length
  --max MAX      maximum name length
  --new          reject names appearing in source data

Examples

Use as a standalone tool

Get a name for a quasi-English woman.

: python names.py --sequence engf engsur
Gayne Fielly

The input files are UTF-8, so let's have a name for a pseudo-Norse god.

: python names.py norsem
Hriðr

Or a French woman with a Japanese father whose mother read too many fantasy novels.

: python names.py --sequence frenchf arthurianf japansur
Sylvaine Isonina Miyami

The --sequence options selects one from each of the name lists chosen; without it, the tool picks one name list at random to use from the lists you select.

: python names.py arthurianm arthurianf normanm normanf normansur saxonm saxonf
Goldry

Generate a bunch of names using all the name source lists as one big list.

: python names.py --count 10 all
Yudeli
Hardal
Clearia
Arrid
Lafi
Heskina
Oddrik
Astonna
Gavittia
Korg

It also does pseudo-Bayer star names based on made-up constellations:

: python names.py --star
Beta Ambertus

If it's important that the results not include a word in the source list, you can add the --new option. For example, if you want a flower species name that is not the name of any real flower:

: python names.py --sequence --new --min 6 --max 18 flowergenus flowerspecies
Uvetinia proccanus

Use as a module

Import the module. Name data sets are loaded on demand; the first time you use a given set it may pause briefly.

: python
Python 3.9.9 | packaged by conda-forge | …
Type "help", "copyright", "credits" or "license" for more information.
>>> import names

To get a single name:

>>> print(names.gen_name( 'norsem' ))
Þorn

You can do name sequences here too:

>>> print(names.gen_names( ['engf','engsur'] ))
Lina Fitter
>>> print(names.gen_names( ['frenchf','arthurianf','japansur'] ))
Jestée Lyona Harasahiro                                                             

The 'all' name set works here too.

>>> print(names.gen_name( 'all' ))
Lùshi 
>>> print(names.gen_name( 'all' ))
Ingarriphan

And stars.

>>> print(names.gen_star_name())
Beta Agapidus

For finer control, you can use an argparse.Namespace as a option container, using the same options as on the command line:

>>> import argparse
>>> long_name = argparse.Namespace()
>>> long_name.count = 1
>>> long_name.min = 20
>>> long_name.max = 80
>>> long_name.new = False
>>> print(names.gen_name( 'engsur', long_name ))
Browichmasstowiteraumpben

...though at present the algorithm isn't guaranteed to terminate with all combinations of length limits and source lists, so use this option with caution.

Name Sets

I've assembled a few name lists from various cultures, collected from various sources, some contemporary and some historical. Many of the names on these lists are probably ridiculous. Many cultures have had names "injected" into them from other cultures over the years, so the lists aren't very "pure". Feel free to alter them as you see fit.

The format is simple: white space ignored, one name per line, lines beginning with # are comments.

The more names on the list, the more likely it is to successfully generate a name.

Lists which include names coming from different languages are more likely to generate unpronounceable names, because it'll be switching orthographic rules in mid-word.

Future Work

Verify behavior with right-to-left languages.

Improve name lists.

Guarantee termination of name generation by hook or by crook.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.