def construct_metaqa_data(self, train_file,
                            test_file):
    """Load MetaQA datasets from files.

    Args:
      train_file: filename for train data
      test_file: filename for test data

    Returns:
      a list of train pairs and test pairs

    """
    self.max_question_len = 0
    train_data, test_data = list(), list()
    for filename, data in zip([train_file, test_file], [train_data, test_data]):
      with gfile.GFile(self.root_dir + filename) as f:
        for line in f:
          line = json.loads(line)
          question = [self.word2id[word] for word in line['question'].split()]
          self.max_question_len = max(self.max_question_len, len(question))
          question_entity = line['question_entities'][0]
          question_entity_id = self.entity2id[question_entity]

          answers = set(line['answers'])
          answer_fact_ids = [
              f_id for (subj, relation, obj), f_id in self.fact2id.items()
              if obj in answers
          ]
          data.append([question, question_entity_id, answer_fact_ids])

    return train_data, test_data
Load MetaQA datasets from files.

    Args:
      train_file: filename for train data
      test_file: filename for test data

    Returns:
      a list of train pairs and test pairs

    
language/emql/data_loader.py