Skip to main content

Name generation library.

Project description

Pynames intended for generation of all sorts of names. Currently it implements generators for character names of different races and cultures:

  • Scandinavian: traditional names;

  • Russian: pagan names;

  • Mongolian: traditional names;

  • Korean: traditional names;

  • Elven: DnD names;

  • Elven: Warhammer names;

  • Goblins: custom names;

  • Orcs: custom names;

  • Iron Kingdoms: caspian midlunder sulese;

  • Iron Kingdoms: dwarf;

  • Iron Kingdoms: gobber;

  • Iron Kingdoms: iossan nyss;

  • Iron Kingdoms: khadoran;

  • Iron Kingdoms: ogrun;

  • Iron Kingdoms: ryn;

  • Iron Kingdoms: thurian morridane;

  • Iron Kingdoms: tordoran;

  • Iron Kingdoms: trollkin.

There are two supported languages : English & Russian. Russian language names are generated with forms for every case of a noun and time.

Currently implemented two generation algorithms:

  • pynames.from_list_generator — names are created from list of predefined words;

  • pynames.from_table_generator — names are created using templates, every part of template is gotten from separate table;

The library is easily extensible. If you need extra functionality (including new languages), please, contact me, post an issue, or just make a pull request.

Installation

pip install pynames

Usage

from pynames import GENDER, LANGUAGE

All generators are divided by “races”, so that all generators of elven names are placed in the module pynames.generators.elven, etc.

from pynames.generators.elven import DnDNamesGenerator
elven_generator = DnDNamesGenerator()

Number of different names (male and female) and for each gender separately.

In [4]: elven_generator.get_names_number()
Out[4]: 1952949936

In [5]: elven_generator.get_names_number(GENDER.MALE)
Out[5]: 976474968

In [6]: elven_generator.get_names_number(GENDER.FEMALE)
Out[6]: 976474968

Fast random name generation.

In [7]: elven_generator.get_name_simple()
Out[7]: u'Elineer'

In [8]: elven_generator.get_name_simple(GENDER.MALE)
Out[8]: u'Caslithdar'

In [9]: elven_generator.get_name_simple(GENDER.MALE, LANGUAGE.EN) # English
Out[9]: u'Mararon'

In [10]: print elven_generator.get_name_simple(GENDER.MALE, LANGUAGE.RU)  # Russian
Ттомусиэл

Instead of text, you can get the Name object with additional functionality.

In [11]: name = elven_generator.get_name()

In [12]: name.translations  # all translations
Out[12]:
{u'm': {u'en': u"ae'Angaithnyn",
        u'ru': [u"\u0430\u044d'\u0410\u043d\u0433\u0430\u0438\u0442\u0442\u043d\u0438\u0438\u043d",
                u"\u0430\u044d'\u0410\u043d\u0433\u0430\u0438\u0442\u0442\u043d\u0438\u0438\u043d\u0430",
                u"\u0430\u044d'\u0410\u043d\u0433\u0430\u0438\u0442\u0442\u043d\u0438\u0438\u043d\u0443",
                u"\u0430\u044d'\u0410\u043d\u0433\u0430\u0438\u0442\u0442\u043d\u0438\u0438\u043d\u0430",
                u"\u0430\u044d'\u0410\u043d\u0433\u0430\u0438\u0442\u0442\u043d\u0438\u0438\u043d\u043e\u043c",
                u"\u0430\u044d'\u0410\u043d\u0433\u0430\u0438\u0442\u0442\u043d\u0438\u0438\u043d\u0435",
                u"\u0430\u044d'\u0410\u043d\u0433\u0430\u0438\u0442\u0442\u043d\u0438\u0438\u043d\u044b",
                u"\u0430\u044d'\u0410\u043d\u0433\u0430\u0438\u0442\u0442\u043d\u0438\u0438\u043d\u043e\u0432",
                u"\u0430\u044d'\u0410\u043d\u0433\u0430\u0438\u0442\u0442\u043d\u0438\u0438\u043d\u0430\u043c",
                u"\u0430\u044d'\u0410\u043d\u0433\u0430\u0438\u0442\u0442\u043d\u0438\u0438\u043d\u043e\u0432",
                u"\u0430\u044d'\u0410\u043d\u0433\u0430\u0438\u0442\u0442\u043d\u0438\u0438\u043d\u0430\u043c\u0438",
                u"\u0430\u044d'\u0410\u043d\u0433\u0430\u0438\u0442\u0442\u043d\u0438\u0438\u043d\u0430\u0445"]}}

In [13]: print u'\n'.join(name.get_forms_for(GENDER.MALE, language=LANGUAGE.RU))
аэ'Ангаиттниин
аэ'Ангаиттниина
аэ'Ангаиттниину
аэ'Ангаиттниина
аэ'Ангаиттниином
аэ'Ангаиттниине
аэ'Ангаиттниины
аэ'Ангаиттниинов
аэ'Ангаиттниинам
аэ'Ангаиттниинов
аэ'Ангаиттниинами
аэ'Ангаиттниинах

In [14]: name.genders
Out[14]: frozenset({u'm'}) # all genders

Project details


Download files

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

Source Distribution

pynames-0.2.4.tar.gz (145.2 kB view details)

Uploaded Source

Built Distribution

pynames-0.2.4-py3-none-any.whl (156.3 kB view details)

Uploaded Python 3

File details

Details for the file pynames-0.2.4.tar.gz.

File metadata

  • Download URL: pynames-0.2.4.tar.gz
  • Upload date:
  • Size: 145.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.10.0 Linux/5.11.0-38-generic

File hashes

Hashes for pynames-0.2.4.tar.gz
Algorithm Hash digest
SHA256 e1db9824a265f8355358e48d8b29096d5a2de09e3cb1404a8ac903e546c0eec8
MD5 9f5e920118d3e89dadbe2470c694a417
BLAKE2b-256 aefa9a4247d7ed95d1aa0144ac2c417f47a62aea8e21171e2fcabe8c3706e17b

See more details on using hashes here.

File details

Details for the file pynames-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: pynames-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 156.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.10.0 Linux/5.11.0-38-generic

File hashes

Hashes for pynames-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8bff40cb217fb6b66528ac9e1e5a4736b4e924eff7db53e9e8781359905e1452
MD5 23fc1e5fd7acaf9211c547d871a2585a
BLAKE2b-256 1a62007e90547faca069f2ae9edfbdcb9e233de3e6f55a63f420cf183cd47f42

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page