From b74be9527c842ec96fbb85cbbf4375e0469ec71d Mon Sep 17 00:00:00 2001 From: Eugene Petkevich Date: Fri, 16 Dec 2022 19:22:40 +0100 Subject: [PATCH] optimize vocabularies --- wordidgen/wordidgen.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/wordidgen/wordidgen.py b/wordidgen/wordidgen.py index 14f8466..e9983b4 100755 --- a/wordidgen/wordidgen.py +++ b/wordidgen/wordidgen.py @@ -42,6 +42,12 @@ VOWELS_CYRILLIC = (VOWELS_HARD[0:1] + VOWELS_SOFT[0:3] CONSONANTS_LATIN = [Consonant(l, l) for l in 'bcdfghjklmnpqrstvwxz'] VOWELS_LATIN = [Vowel(l, False) for l in 'aeiouy'] +VOCABULARIES = { + 'cyrillic': (CONSONANTS_CYRILLIC, VOWELS_CYRILLIC), + 'extcyrillic': (CONSONANTS_EXTCYRILLIC, VOWELS_CYRILLIC), + 'latin': (CONSONANTS_LATIN, VOWELS_LATIN) +} + class WordGenerator: """Generate word by combining syllables""" @@ -102,15 +108,7 @@ def main(): help='set of letters to use ' '(cyrillic, extcyrillic, latin)') args = parser.parse_args() - if args.vocabulary == 'cyrillic': - consonants = CONSONANTS_CYRILLIC - vowels = VOWELS_CYRILLIC - elif args.vocabulary == 'extcyrillic': - consonants = CONSONANTS_EXTCYRILLIC - vowels = VOWELS_CYRILLIC - elif args.vocabulary == 'latin': - consonants = CONSONANTS_LATIN - vowels = VOWELS_LATIN + consonants, vowels = VOCABULARIES[args.vocabulary] word_generator = WordGenerator(length=args.length, consonants=consonants, vowels=vowels) -- 2.17.1