def fn_jaro(len1, len2, num_matches, half_transposes, typo_score, typo_scale):
    """Calculate the classic Jaro metric between two strings.

    The strings have lengths 'len1' and 'len2'. 'num_matches' and
    'half_transposes' are the output of the count_matches() and
    count_half_tranpositions() functions.

    'typo_score' is an optional argument, produced by the count_typos()
    function if you decide to check the strings for typos with a given
    typographical mapping. The typo score will be scaled by 'typo_scale'
    before being used."""
    if not len1:
        if not len2:
            return 1.0
        return 0.0
    if not num_matches:
        return 0.0
    similar = typo_score / typo_scale + num_matches
    weight = similar / len1 + similar / len2 + (num_matches - 
        half_transposes // 2) / num_matches
    return weight / 3
