import bisect


def _get_properties_ranking_using_partition_rule(properties_ranking,
                                                 partition_rule):
    """Take the contents of the properties ranking file and produce a dictionary
    of css properties with their group number based on the partition_rule

    Args:
        properties_ranking: rankings map as read from CSSPropertyRanking.json5
        partition_rule: cumulative distribution over properties_ranking

    Returns:
        dictionary with keys are css properties' name values are the group
        that each css properties belong to. Smaller group number is higher
        popularity in the ranking.
    """
    return dict(
        zip(properties_ranking, [
            bisect.bisect_left(partition_rule,
                               float(i) / len(properties_ranking)) + 1
            for i in range(len(properties_ranking))
        ]))