def get_f1(self, paired_anno: annotation.PairedAnnotation) -> float:
    """Computes token-level overlap of the two questions.

    This is equivalent to Rouge-1's f-measure or the commonly reported
    SQuAD F1 in question answering datasets.

    Args:
      paired_anno: pair of annotation and prediction.

    Returns:
      token-level f1 of the overlap between predicted and annotated.
    """
    gold_set = set(paired_anno.gold_question.split())
    pred_set = set(paired_anno.pred_question.split())
    if not pred_set and not gold_set:
      return 1.0
    elif not pred_set or not gold_set:
      return 0.0
    overlap_words = gold_set & pred_set
    recall = len(overlap_words) / len(gold_set)
    precision = len(overlap_words) / len(pred_set)
    if (summed := recall + precision) == 0.0:
      return 0.0
    f1 = 2 * recall * precision / summed
    return f1
Computes token-level overlap of the two questions.

    This is equivalent to Rouge-1's f-measure or the commonly reported
    SQuAD F1 in question answering datasets.

    Args:
      paired_anno: pair of annotation and prediction.

    Returns:
      token-level f1 of the overlap between predicted and annotated.
    
language/diffqg/metrics.py