def feature_dict_map(weights):
    """construct a dict with features from a weights dictionary

    :param weights: dictionary mapping features to numeric weights
    :return: dictionary from features to a (index, weight)
    """

    if type(weights) is dict:
        result = {k: (i, weights[k]) for i, k in enumerate(weights)}
    else:
        result = {k: (i, 1) for i, k in enumerate(weights)}
    return result