input: Write a function to generate a Markov chain given a text input. The function should process the input text to create a dictionary where each word maps to a list of subsequent words and their frequencies. The function should then generate and return a random text string based on the Markov chain using the frequencies of word occurrences. If the input text is empty, the function should return an empty string.
  assert generateMarkov("Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, `and what is the use of a book,' thought Alice `without pictures or conversation?'") == "expected output here"
  assert generateMarkov("") == ""
output: def generateMarkov(text):
      if not text:
          return ""
      
      words = text.split()
      chain = {}
      
      for i in range(len(words) - 1):
          current_word = words[i]
          next_word = words[i + 1]
          
          if current_word not in chain:
              chain[current_word] = {}
          
          if next_word not in chain[current_word]:
              chain[current_word][next_word] = 0
          
          chain[current_word][next_word] += 1
      
      import random
      result = []
      current_word = random.choice(list(chain.keys()))
      
      while current_word in chain:
          result.append(current_word)
          next_words = chain[current_word]
          total_freq = sum(next_words.values())
          rand_val = random.randint(1, total_freq)
          
          cumulative_freq = 0
          for word, freq in next_words.items():
              cumulative_freq += freq
              if rand_val <= cumulative_freq:
                  current_word = word
                  break
      
      return ' '.join(result)