def choose_random_question(para_text, question_sampling_scheme):
  """Sample a paragraph's words to form a question."""
  if "anchor_gaussian" in question_sampling_scheme:
    q_length = np.random.randint(5, 15)
    para_tokens = para_text.split()
    anchor = np.random.randint(0, len(para_tokens))

    question = []
    std_dev = max(int(len(para_tokens) / 8.0), int(q_length))

    for _ in range(q_length):
      token_index = -1
      while token_index < 0 or token_index >= len(para_tokens):
        token_index = int(np.round(np.random.normal(loc=anchor, scale=std_dev)))
      question.append(para_tokens[token_index])

    return " ".join(question)

  elif "random" in question_sampling_scheme:
    q_length = np.random.randint(5, 15)
    para_tokens = para_text.split()
    question = []

    for _ in range(q_length):
      question.append(random.choice(para_tokens))

    return " ".join(question)
Sample a paragraph's words to form a question.
language/bert_extraction/steal_bert_qa/data_generation/preprocess_util.py