def update_metrics(self, pred_answers, easy_answers, hard_answers):
    """Compute and update metrics.

    Args:
      pred_answers: a list of predicted answers.
      easy_answers: a set of easy answers, i.e. answers can be inferred from
        train kb.
      hard_answers: a set of hard answers, i.e. answers can only be inferred
        from test kb.
    """
    # Check the correctness of the top 10 "hard" predictions.
    hits = [False] * 10
    i = 0
    mrr = 0.0
    for a in pred_answers:
      a = self.convert_entid2q2b(a)
      if i >= 10: break
      # Exclude easy answers (answers exposed in the training kb).
      if a in easy_answers:
        continue
      hits[i] = (a in hard_answers)
      i += 1
      mrr = max(1.0 / float(i) if a in hard_answers else 0.0, mrr)

    # Add to metrics.
    self.metrics['hits@1'] += float(any(hits[:1]))
    self.metrics['hits@3'] += float(any(hits[:3]))
    self.metrics['hits@10'] += float(any(hits[:10]))
    self.metrics['mrr'] += mrr
    self.total += 1.0
Compute and update metrics.

    Args:
      pred_answers: a list of predicted answers.
      easy_answers: a set of easy answers, i.e. answers can be inferred from
        train kb.
      hard_answers: a set of hard answers, i.e. answers can only be inferred
        from test kb.
    
language/emql/eval.py