def calc_num_metric(predicted_number, actual_number):
    """
    How similar are 2 numbers of references?
    The difference between the predicted and actual numbers of references
    as a percentage of the actual number
    """

    # In the case of 0 references (some documents don't have references but do
    # have a reference section), set actual_number to the closest integer, 1.
    # This introduces some small error, but avoids the script throwing a math error
    if actual_number == 0:
        actual_number = 1

    metric = abs(100*((predicted_number - actual_number) / actual_number))

    return metric