def iou_score(sent_a, sent_b):
  """Token intersection over union score between two sentences."""
  sent_a_tokens = set(sent_a.split(" "))
  sent_b_tokens = set(sent_b.split(" "))
  intersection = sent_a_tokens & sent_b_tokens
  union = sent_a_tokens | sent_b_tokens
  return len(intersection) / len(union)
Token intersection over union score between two sentences.
language/fruit/rendering_utils.py