text: # (c) 2019 Anton Zakharov
  # This code is licenced under the MIT license (see license.txt for details)
  
  import json
  import random
  
  with open("data/city_words.json") as f:
      temp = json.load(f)
      consonant_data = temp["consonants"]
      vowel_data = temp["vowels"]
  
  consonants = list()
  for sound in consonant_data:
      consonants.extend(sound["graphemes"])
  
  vowels = list()
  for sound in vowel_data:
      vowels.extend(sound["graphemes"])
  
  currentLetterVowel = bool(random.randint(0, 1))
  
  syllables = int(input("# of syllables:\n"))
  numWords = int(input("# of words:\n"))
  
  words = []
  
  for i in range(numWords):
      word = ""
      for i in range(syllables):
          syllable = ""
          if (currentLetterVowel):
              randomIndex = random.randint(0, len(vowels) - 1)
              syllable = vowels[randomIndex]
          else:
              randomIndex = random.randint(0, len(consonants) - 1)
              syllable = consonants[randomIndex]
          currentLetterVowel = not currentLetterVowel
          word += syllable
  
      # make sure first characters dont repeat
      if (word[0] == word[1]):
          word = word[1:]
  
      # remove triple letters
      triples = []
      for index in range(len(word) - 2):
          if (word[index] == word[index + 1] == word[index + 2]):
              triples.append(index)
      for index in reversed(triples):
          word = word[:index] + word[index + 1:]
  
      words.append(word)
  
  print(words)
  