def generate_clustered_data(stories, clusters):
    """
    clusters is a dict with an index as key and values as
    story IDs as stored in MongoDB

    clustered is a list of dictionaries. Each dictionary is a cluster
    of stories. Internal dicts have as keys the
    storyid and as values the actual story content. An additional key is
    the cluster ID.
    """
    clustered = []
    for x in clusters.keys():
        mini = {'clust_id': x}
        for sid in clusters[x]:
            mini[sid] = stories[sid]

        clustered.append(mini)

    return clustered