def read_qrys_to_embed(input_file):
  """Read json file containing Wikidata queries into list of SquadExample."""
  with tf.gfile.Open(input_file, "r") as reader:
    examples = []
    for line in tqdm(reader):
      item = json.loads(line.strip())
      qas_id = item["id"]
      if "name" in item["subject"]:
        entity_text = item["subject"]["name"]
      else:
        entity_text = random.choice(item["subject"]["mentions"])["text"]
      question_text = (
          entity_text + " . " + random.choice(item["relation"]["text"]))

      is_impossible = True
      start_position = -1
      end_position = -1
      orig_answer_text = ""

      example = SquadExample(
          qas_id=qas_id,
          question_text=question_text,
          entity_text=entity_text,
          doc_tokens=["dummy"],
          orig_answer_text=orig_answer_text,
          start_position=start_position,
          end_position=end_position,
          is_impossible=is_impossible)
      examples.append(example)

  return examples
Read json file containing Wikidata queries into list of SquadExample.
language/labs/drkit/run_dualencoder_lsf.py