def read_examples(self, queries_file, entity2id):
    """Read a json file into a list of Example."""
    self.max_qry_answers = 0
    num_qrys_without_answer, num_qrys_without_all_answers = 0, 0
    num_qrys_without_entity, num_qrys_without_all_entities = 0, 0
    tf.logging.info("Reading examples from %s", queries_file)
    with tf.gfile.Open(queries_file, "r") as reader:
      examples = []
      for line in tqdm(reader):
        item = json.loads(line.strip())

        qas_id = item["_id"]
        question_text = item["question"]
        answer_entities = []
        for answer in item["supporting_facts"]:
          if answer["kb_id"].lower() in entity2id:
            answer_entities.append(entity2id[answer["kb_id"].lower()])
        if not answer_entities:
          num_qrys_without_answer += 1
          if self.is_training:
            continue
        if len(answer_entities) != len(item["supporting_facts"]):
          num_qrys_without_all_answers += 1
        subject_entities = []
        for entity in item["entities"]:
          if entity["kb_id"].lower() in entity2id:
            subject_entities.append(entity["kb_id"].lower())
        if not subject_entities:
          num_qrys_without_entity += 1
          if self.is_training:
            continue
        if len(subject_entities) != len(item["entities"]):
          num_qrys_without_all_entities += 1

        if len(answer_entities) > self.max_qry_answers:
          self.max_qry_answers = len(answer_entities)

        example = Example(
            qas_id=qas_id,
            question_text=question_text,
            subject_entity=subject_entities,
            answer_entity=answer_entities,
            inference_chain=item["type"])
        examples.append(example)
    tf.logging.info("Number of valid questions = %d", len(examples))
    tf.logging.info("Questions without any answer = %d",
                    num_qrys_without_answer)
    tf.logging.info("Questions without all answers = %d",
                    num_qrys_without_all_answers)
    tf.logging.info("Questions without any entity = %d",
                    num_qrys_without_entity)
    tf.logging.info("Questions without all entities = %d",
                    num_qrys_without_all_entities)
    tf.logging.info("Maximum answers per question = %d", self.max_qry_answers)

    return examples
Read a json file into a list of Example.
language/labs/drkit/input_fns.py