def result_to_metrics(result):
    """Specific for the result dictionary of simpletransformers binary classification,
    which is a dictionary including keys: `tp`, `fp`, `tn`, and `fn`.

    TP = True Positive
    FP = False Positive
    TN = True Negative
    FN = False Negative

    accuracy = (TP + TN) / (TP + FP + TN + FN)
    precision = TP / (TP + FP)
    recall = TP / (TP + FN)
    :returns accuracy, precision, recall
    """
    accuracy = (result['tp'] + result['tn']) / (result['tp'] + result['fp'] + result['tn'] + result['fn'])
    positives = result['tp'] + result['fp']
    if positives > 0:
        precision = result['tp'] / (result['tp'] + result['fp'])
    else:
        # If there are no positives, we set the precision to 1
        precision = 1.0
    labeled_positives = result['tp'] + result['fn']
    if labeled_positives > 0:
        recall = result['tp'] / (result['tp'] + result['fn'])
    else:
        # If there are no labelled positives, we set the recall to 1
        recall = 1.0
    if precision + recall > 0:
        f1 = (2 * precision * recall) / (precision + recall)
    else:
        f1 = 0.0
    return accuracy, precision, recall, f1