def f1(gt_s, gt_e, pr_s, pr_e):
    """
    Evaluate F1 score of a predicted span over a ground truth span.
    Args:
        gt_s: index of the ground truth start position
        gt_e: index of the ground truth end position
        pr_s: index of the predicted start position
        pr_e: index of the predicted end position
    """
    gt = {idx for idx in range(gt_s, gt_e+1)}
    pr = {idx for idx in range(pr_s, pr_e+1)}
    intersection = gt.intersection(pr)
    prec = 1. * len(intersection) / len(pr)
    rec =  1. * len(intersection) / len(gt)
    f1_score = (2. * prec * rec) / (prec+rec) if prec+rec != 0. else 0.
    return f1_score