Trees | Indices | Help |
---|
|
1 #!/bin/env python 2 # encoding: utf-8 3 4 # Name Generator written by Pointon: 5 # http://www.uselesspython.com/showcontent.php?author=27 6 7 # Adapted by Arne Babenhauserheide 2007 8 9 ## I got sick of the absence of plain weird and quirky name generators out there. This comes up with unpronounceable results about 1/5th of the time. 10 ## The namegen function has three parameters: lower_limit and upper_limit govern the length. ratio governs the vowels:consonants ratio. The lower the ratio, the less vowels per consonant. 11 12 13 import random 14 15 result = "" 16 fricatives = ["j", "ch", "h", "s", "sh", "th", "f", "v", "z"] 17 vowels = ["a", "e", "i", "o", "u", "y", "ya", "ye", "yi", "yo", "yu", "wa", "we", "wi", "wo", "wu", "ae", "au", "ei", "ie", "io", "iu", "ou", "uo", "oi", "oe", "ea"] 18 consonantsNormal = ["c", "g", "t", "d", "p", "b", "x", "k", "ck", "ch"] 19 consonantsNasal = ["n", "m", "ng", "nc"] 20 randomLength = 0 21 vowelSyllables = 0 22 vowelRatio = 0 2325 ratio = ratio + 3 26 if ratio < 4: 27 ratio = 4 28 elif ratio > 14: 29 ratio = 14 30 global result, vowelSyllables, randomLength, vowelRatio 31 vowelRatio = ratio 32 result = "" 33 vowelSyllables = 0 34 randomLength = random.randrange(lower_limit, upper_limit) 35 sylgen() 36 return result.capitalize()3739 global result, vowelSyllables, randomLength, syllableOnlyVowels, vowelRatio 40 syllableOnlyVowels = 1 41 maincongen() 42 if vowelSyllables < (vowelRatio/4): 43 vowgen() 44 maincongen() 45 if syllableOnlyVowels == 1: 46 vowelSyllables = vowelSyllables + 1 47 if len(result) < randomLength: 48 sylgen()4951 global result, vowelSyllables, syllableOnlyVowels, fricatives 52 result = result + fricatives[random.randrange(0, len(fricatives))] 53 syllableOnlyVowels = 0 54 vowelSyllables = 055 5961 global result, vowelSyllables, randomLength, syllableOnlyVowels, consonantsNormal 62 result = result + consonantsNormal[random.randrange(0, len(consonantsNormal), 1)] 63 syllableOnlyVowels = 0 64 vowelSyllables = 06567 global result, vowelSyllables, syllableOnlyVowels 68 if random.randrange(0, 2) == 0: 69 result = result + "r" 70 else: 71 result = result + "l" 72 syllableOnlyVowels = 0 73 vowelSyllables = 07476 global result, vowelSyllables, syllableOnlyVowels, consonantsNasal 77 result = result + consonantsNasal[random.randrange(0, len(consonantsNasal))] 78 syllableOnlyVowels = 0 79 vowelSyllables = 08082 global result, randomLength, vowelRatio 83 if len(result) < randomLength: 84 randomNumber = random.randrange(0, vowelRatio) 85 if randomNumber == 0: 86 fricgen() 87 if len(result) < randomLength: 88 randomNumber = random.randrange(0, vowelRatio/4 * 3) 89 if randomNumber == 0: 90 congen() 91 if len(result) < randomLength: 92 randomNumber = random.randrange(0, vowelRatio/2) 93 if randomNumber == 0: 94 con2gen() 95 elif randomNumber == 1: 96 con2gen() 97 elif randomNumber == 2: 98 con3gen() 99 elif randomNumber == 1: 100 congen() 101 if len(result) < randomLength: 102 randomNumber = random.randrange(0, vowelRatio/2) 103 if randomNumber == 0: 104 con2gen() 105 elif randomNumber == 2: 106 con2gen() 107 elif randomNumber == 3: 108 con3gen()109
Trees | Indices | Help |
---|
Generated by Epydoc 3.0alpha3 on Sun Oct 28 23:11:31 2007 | http://epydoc.sourceforge.net |