Created
July 11, 2018 08:33
-
-
Save SuperFola/b16c6e733dd6f7c9f438831aef1390e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import string | |
import random | |
syllable_patterns = [ | |
# _ => consonant | |
# -, + => vowel | |
"_-" | |
, "_-+" | |
, "__-" | |
, "-_" | |
] | |
vowels = "aeiouy" | |
consonants = ''.join(c for c in string.ascii_lowercase if c not in vowels) | |
def create_syllable(): | |
pattern = random.choice(syllable_patterns) | |
output = pattern.replace('_', random.choice(consonants)) \ | |
.replace('-', random.choice(vowels)) \ | |
.replace('+', random.choice(vowels)) | |
return output | |
def main(args): | |
count = 10 | |
minimum = 2 | |
maximum = 4 | |
if args: | |
try: | |
count = int(args[0]) | |
except ValueError: | |
print("Couldn't parse integer for 'count'") | |
if args[1:]: | |
try: | |
minimum = int(args[1]) | |
except ValueError: | |
print("Couldn't parse integer for 'minimum'") | |
if args[2:]: | |
try: | |
maximum = int(args[2]) | |
except ValueError: | |
print("Couldn't parse integer for 'maximum'") | |
output = "" | |
for i in range(count): | |
output += "{:16}".format(''.join(create_syllable() for i in range(random.randrange(minimum, maximum)))) | |
if i and not i % 5: | |
output += "\n" | |
print(output) | |
if __name__ == '__main__': | |
main(sys.argv[1:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment