def eval(predict, groundtruth):
    """计算预测结果的准确率、召回率、F1

    Args:
        predict (list): 预测结果
        groundtruth (list): 真实结果

    Returns:
        tuple(precision, recall, f1): 精确率, 召回率, f1
    """
    assert len(predict) == len(groundtruth)
    tp, fp, tn, fn = 0, 0, 0, 0
    for i in range(len(predict)):
        right = len([j for j in predict[i] if j in groundtruth[i]])
        tp += right
        fn += len(groundtruth[i]) - right
        fp += len(predict[i]) - right
    precision = tp / (tp + fp)
    recall = tp / (tp + fn)
    f1 = 2 * precision * recall / (precision + recall)
    return precision, recall, f1