Skip to main content

Simple Python package for generate unique nikcname, e.g. Cool Crow, Purple Duck, Red Brave Tiger. It supports both English and Russian (including gender).

Project description

Nickname Generator

The Nickname Generator package provides simple functions to generate random nicknames.

Installation

pip install nickname-gen

Usage

This package provides two main methods for generating nicknames: get_random_en_nickname and get_random_ru_nickname.

get_random_en_nickname

Generates a random nickname in English.

from nickname_gen.generator import Generator
from nickname.gen.wtypes import WordList, WordType, Lang

# Using default parameters
nickname = Generator.get_random_en_nickname()
print(nickname)  # Example: 'Green Brave Tiger'

# Using a custom list of parts
my_adjectives = WordList("My Adjectives", Lang.EN, ["cool", "awesome"], WordType.ADJECTIVE)
my_nouns = WordList("My Nouns", Lang.EN, ["python", "developer"], WordType.NOUN)
nickname = Generator.get_random_en_nickname(combos=[my_adjectives, my_nouns])
print(nickname)  # Example: 'Awesome Developer'

# Using a custom separator
nickname = Generator.get_random_en_nickname(separator="-")
print(nickname)  # Example: 'Green-Brave-Tiger'

# Using a custom style
nickname = Generator.get_random_en_nickname(style=StyleEnum.UPPER)
print(nickname)  # Example: 'GREEN BRAVE TIGER'

This method can be customized by passing the following arguments:

  • combos (WordList object, optional): a list of parts to compose the nickname. By default, it uses the lists of adjectives, colors, and animals in English.
  • separator (string, optional): the separator between nickname parts. By default, it uses a space.
  • style (StyleEnum instance, optional): the style of the nickname. By default, it uses StyleEnum.CAPITAL. Available options:
    • StyleEnum.CAPITAL (the first letter of each word is capitalized),
    • StyleEnum.UPPER (all letters are uppercase),
    • StyleEnum.LOWER (all letters are lowercase).

get_random_ru_nickname

Generates a random nickname in Russian, considering the gender of the noun.

from nickname_gen import Generator

# Using default parameters
nickname = Generator.get_random_ru_nickname()
print(nickname)  # Example: 'Зеленый Храбрый Тигр' ('Green Brave Tiger')

# Using custom parameters (similar to the English version)
...

This method can be customized by passing the same arguments as for get_random_en_nickname.

Dependencies and Possible Errors

The nickname_gen library uses the following dependency:

  • pymorphy3 - for determining the gender of the noun when generating Russian nicknames.

When using the get_random_en_nickname and get_random_ru_nickname methods, the following exceptions may occur:

  • WordsAmountError: if there are fewer than one word in the list.
  • WordListAmountError: if there are fewer than two elements in the list of combinations.
  • WordListNounAmountError: if there is more than one list of nouns in the list of combinations.
  • LangError: if the languages of the word lists in the combinations differ.
  • WordTypeError: if the list of combinations does not contain lists of nouns and adjectives.
  • GenderNotFoundError: if the gender of the noun could not be determined (for Russian language only).

History and Inspiration

The idea for creating this package arose from the need to generate unique nicknames for one of my projects. Initially, I needed to generate random, but readable and memorable usernames.

Additional inspiration came from the user names and avatars that Google Docs assigns when collaborating on a document. They consist of an adjective and an animal name, such as "Unidentified Capybara," along with a random-colored icon of that animal. They are much more memorable than a set of random letters and numbers, but they do not accurately identify the user.

Based on this idea, I decided to create a package that would allow generating similar nicknames in different languages, while adding additional options to customize the format and style of the generated names, as well as the ability to use your own set of words. The result was the Nickname Generator package, which is now available for anyone to use.

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

nickname_gen-0.1.5.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nickname_gen-0.1.5-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

File details

Details for the file nickname_gen-0.1.5.tar.gz.

File metadata

  • Download URL: nickname_gen-0.1.5.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Windows/11

File hashes

Hashes for nickname_gen-0.1.5.tar.gz
Algorithm Hash digest
SHA256 a1b412774faa880b896ab5a3d9bf2a7adb4a9a7f427c142ed44b04eb9bff5386
MD5 25b64c8bbebc86fda33d0a4f01092e51
BLAKE2b-256 796c6df47fdd3c2d54645bf07f5dd593834e675893567e32b4fb7a9ca8e4e65c

See more details on using hashes here.

File details

Details for the file nickname_gen-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: nickname_gen-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 20.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Windows/11

File hashes

Hashes for nickname_gen-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 698407b30678d1968a03f3bb8b1a97e229d6cd8fc00e83e016a89ce836fe0cd0
MD5 81c2ae540240415c7f1cabd812e35f01
BLAKE2b-256 268ad2f3b20264b49274150422518ee0481ff80f6e3dd0f039d6f73701530eba

See more details on using hashes here.

Supported by

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