def merge(tags, weights=None):
    """
    tags: a list of tags
    weights: alist of weights, the sum shuld be 1
    """
    if not weights:
        weights = [1.0/len(tags) for i in range(len(tags))]

    stat = {}
    for i, tag in enumerate(tags):
        for t in tag:
            stat[t] = stat.get(t, 0) + weights[i]

    return stat