def eval(self, tf_prediction):
    """Eval one tf_prediction.

    Args:
      tf_prediction: a dictionary of predicted values

    """
    features = tf_prediction['query']
    pred_answers = tf_prediction['answer_ids']

    # Reformat queries into the Query2Box format. There's not a simple
    # way to automatically structure the input. Again, we hard code their
    # input format during parsing for simplicity.
    if self.task == '1c':
      ent, rel = features
      ent = self.convert_entid2q2b(ent)
      rel = self.convert_relid2q2b(rel)
      query = ((ent, (rel,)),)
    elif self.task == '2c':
      ent, rel1, rel2 = features
      ent = self.convert_entid2q2b(ent)
      rel1 = self.convert_relid2q2b(rel1)
      rel2 = self.convert_relid2q2b(rel2)
      query = ((ent, (rel1, rel2)),)
    elif self.task == '3c':
      ent, rel1, rel2, rel3 = features
      ent = self.convert_entid2q2b(ent)
      rel1 = self.convert_relid2q2b(rel1)
      rel2 = self.convert_relid2q2b(rel2)
      rel3 = self.convert_relid2q2b(rel3)
      query = ((ent, (rel1, rel2, rel3)),)
    elif self.task == '2i' or self.task == '2u':
      ent1, rel1, ent2, rel2 = features
      ent1 = self.convert_entid2q2b(ent1)
      ent2 = self.convert_entid2q2b(ent2)
      rel1 = self.convert_relid2q2b(rel1)
      rel2 = self.convert_relid2q2b(rel2)
      query = ((ent1, (rel1,)), (ent2, (rel2,)))
    elif self.task == '3i':
      ent1, rel1, ent2, rel2, ent3, rel3 = features
      ent1 = self.convert_entid2q2b(ent1)
      ent2 = self.convert_entid2q2b(ent2)
      ent3 = self.convert_entid2q2b(ent3)
      rel1 = self.convert_relid2q2b(rel1)
      rel2 = self.convert_relid2q2b(rel2)
      rel3 = self.convert_relid2q2b(rel3)
      query = ((ent1, (rel1,)), (ent2, (rel2,)), (ent3, (rel3,)))
    elif self.task == 'ic' or self.task == 'uc':
      ent1, rel1, ent2, rel2, rel3 = features
      ent1 = self.convert_entid2q2b(ent1)
      ent2 = self.convert_entid2q2b(ent2)
      rel1 = self.convert_relid2q2b(rel1)
      rel2 = self.convert_relid2q2b(rel2)
      rel3 = self.convert_relid2q2b(rel3)
      query = ((ent1, (rel1,)), (ent2, (rel2,)), rel3)
    elif self.task == 'ci':
      ent1, rel1, rel2, ent2, rel3 = features
      ent1 = self.convert_entid2q2b(ent1)
      ent2 = self.convert_entid2q2b(ent2)
      rel1 = self.convert_relid2q2b(rel1)
      rel2 = self.convert_relid2q2b(rel2)
      rel3 = self.convert_relid2q2b(rel3)
      query = ((ent1, (rel1, rel2)), (ent2, (rel3,)))
    else:
      raise ValueError

    all_ans = self.answers[query]
    hard_ans = self.hard_answers[query]
    easy_ans = all_ans - hard_ans
    assert len(easy_ans) == len(all_ans) - len(hard_ans)

    self.update_metrics(pred_answers, easy_ans, hard_ans)
Eval one tf_prediction.

    Args:
      tf_prediction: a dictionary of predicted values

    
language/emql/eval.py