Random Word Constructor.py
import random
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
vowels = ['a', 'e', 'i', 'o', 'u']
consensnts = [x for x in alphabet if x not in vowels]
starting_letters = ['c', 'd', 'g', 'h', 'i', 'j', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'y', 'z' ]
def syl_CV(): # a list of C-V syllables
return [x + y for x in consensnts for y in vowels if x != y]
def two_syl_word_con(): #a list of C-V-C-V words of length 4
return [x + y for x in syl_CV() for y in syl_CV()]
def syl_VC(): #a list of V-C syllables
return [x + y for x in vowels for y in consensnts if x != y]
def syl_CVV():
return [x + y + z for x in consensnts for y in vowels for z in vowels if y != z]
def syl_VC_VC_suffix(): #returns a list of V-C-V-C suffixes of length 4.
return [x + y for x in syl_VC() for y in syl_VC()]
def syl_VV_suffix():
return [x + y for x in vowels for y in vowels if x + y != 'ii' and x + y != 'uu']
def construct_random_word(length):
word = ''
syllables = syl_CV()
while len(word) < length:
word += syl_CV()[random.randrange(len(syllables))]
return word