def exact_match(targets, predictions):
  """Measures exact match of targets and predictions."""
  numerator = 0
  denominator = 0
  for target, prediction in zip(targets, predictions):
    if target["normalized_targets"] == prediction["normalized_targets"]:
      numerator += 1
    denominator += 1
  return {"exact_match": numerator / (denominator + 1e-13)}
Measures exact match of targets and predictions.
language/fruit/metrics.py