text: """
  Generate some fake hypothesis data to better test our metrics
  with the builtin reference corpus.
  """
  import argparse
  import itertools
  
  import numpy.random as random
  from lsdscc.ds import DEFAULT_EOS as EOS
  from lsdscc import ReferenceSet
  
  # For output to be more readable.
  EOS = ' %s ' % EOS
  
  
  def flatten(reference_set):
      return list(itertools.chain.from_iterable(reference_set))
  
  
  def iter_hypothesis_set(reference_corpus):
      """
      The fake data is generated by sampling the reference corpus.
  
      :param reference_corpus:
      :return:
      """
      for refset in builtin_corpus:
          refset = flatten(refset)
          random.shuffle(refset)
          # Take a half of it.
          sample = refset[:len(refset) // 2]
          for reference in sample:
              # Make the words in a sentence out of order.
              random.shuffle(reference)
          yield [' '.join(ref) for ref in sample]
  
  
  if __name__ == '__main__':
      parser = argparse.ArgumentParser()
      parser.add_argument('output', help='where to write the fake hypothesis')
      args = parser.parse_args()
  
      builtin_corpus = ReferenceSet.load_json_corpus()
      hypothesis_corpus = list(iter_hypothesis_set(builtin_corpus))
      assert len(builtin_corpus) == len(hypothesis_corpus)
  
      with open(args.output, 'w') as f:
          for hs in hypothesis_corpus:
              print(EOS.join(hs), file=f)
  