def precision_ranges(result2rank, total_terms):
    """Computes precision at standard cutoff ranks: [5, 10, 15, 20, 30, 100, 200, 500, 1000]

    Args:
        result2rank: A dict of source to ranks of good translation candidates.
        total_terms: The expected term count.

    Returns:
        A dict containing a precision value for each cutoff rank

    """
    map_of_prec = dict()
    for cutoff in [5, 10, 15, 20, 30, 100, 200, 500, 1000]:
        map_of_prec[cutoff] = sum(1.0 for ranks in result2rank.values() if len([r for r in ranks if r <= cutoff]) > 0) / total_terms
    return map_of_prec