namegen.py 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import random
  2. consonants = ['b', 'v', 'g', 'd', 'zh', 'z', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'f', 'kh', 'ts', 'ch', 'sh', 'sch']
  3. vowels = ['a', 'e', 'i', 'o', 'u', 'y']
  4. endings = ['ov', 'ev', 'in', 'yn', 'ski', 'sky', 'ova', 'eva', 'ina', 'yna', 'skaya', 'skya']
  5. def generate_nickname():
  6. """Generates a random nickname that sounds vaguely Russian."""
  7. # Start with a consonant or vowel
  8. if random.random() < 0.7: # Higher chance to start with a consonant
  9. nickname = random.choice(consonants)
  10. else:
  11. nickname = random.choice(vowels)
  12. # Add 1-2 more syllables
  13. for _ in range(random.randint(1, 2)):
  14. nickname += random.choice(vowels)
  15. nickname += random.choice(consonants)
  16. # Optionally add an ending
  17. if random.random() < 0.5:
  18. nickname += random.choice(endings)
  19. return nickname.capitalize()
  20. # import random
  21. # # List of common Russian consonant sounds (including some consonant clusters)
  22. # consonants = [
  23. # 'b', 'v', 'g', 'd', 'z', 'k', 'l', 'm', 'n',
  24. # 'p', 'r', 's', 't', 'f', 'kh', 'ts', 'ch',
  25. # 'sh', 'zh', 'bl', 'br', 'pl', 'pr', 'sk', 'sl',
  26. # 'sm', 'sn', 'sp', 'st', 'str', 'tr', 'dr', 'kr',
  27. # 'gr', 'gl', 'kl', 'zl', 'shch', 'sch'
  28. # ]
  29. # # List of Russian vowel sounds
  30. # vowels = [
  31. # 'a', 'e', 'i', 'o', 'u', 'y', 'ya', 'ye',
  32. # 'yo', 'yu', 'ia', 'ie', 'io', 'iu', 'ei'
  33. # ]
  34. # # Possible ending consonant sounds (including empty string for open syllables)
  35. # end_consonants = [
  36. # '', 'b', 'v', 'g', 'd', 'z', 'k', 'l', 'm', 'n',
  37. # 'p', 'r', 's', 't', 'f', 'kh', 'ts', 'ch',
  38. # 'sh', 'zh', 'st', 'sk', 'nk', 'ng', 'zd', 'nd'
  39. # ]
  40. # def generate_syllable():
  41. # """Generate a syllable with optional onset and coda."""
  42. # syllable = ''
  43. # # Decide whether to have an onset (70% chance)
  44. # if random.random() < 0.7:
  45. # onset = random.choice(consonants)
  46. # syllable += onset
  47. # # Choose a vowel
  48. # vowel = random.choice(vowels)
  49. # syllable += vowel
  50. # # Decide whether to have a coda (50% chance)
  51. # if random.random() < 0.5:
  52. # coda = random.choice(end_consonants)
  53. # syllable += coda
  54. # return syllable
  55. # def generate_word(min_syllables=2, max_syllables=2):
  56. # """Generate a Russian-like word consisting of a random number of syllables."""
  57. # syllable_count = random.randint(min_syllables, max_syllables)
  58. # word = ''
  59. # for _ in range(syllable_count):
  60. # syllable = generate_syllable()
  61. # word += syllable
  62. # return word
  63. # def generate_russian_like_words(number_of_words):
  64. # """Generate a list of Russian-like words."""
  65. # words = []
  66. # for _ in range(number_of_words):
  67. # word = generate_word()
  68. # words.append(word)
  69. # return words
  70. # # Example usage:
  71. # if __name__ == "__main__":
  72. # number_of_words_to_generate = 10
  73. # russian_like_words = generate_russian_like_words(number_of_words_to_generate)
  74. # for word in russian_like_words:
  75. # print(word)