from typing import Dict
from typing import Any


def convert_drive_files_old_to_new(old: Dict[str, Any]) -> Dict[str, Any]:
    """Convert data from the original format (which had "answers-cleaned" field) to a clearer format."""
    question_id = old["questionid"]
    raw = old["raw-original-answers"]
    clusters = {
        f"{question_id}.{cluster_num}": {
            "count": cluster["count"],
            "answers": cluster["answers"],
        }
        for cluster_num, cluster in enumerate(old["answers-cleaned"])
    }
    num_answers = sum([cluster["count"] for cluster in clusters.values()])
    new = {
        "metadata": {
            "id": question_id,
            "source": "umass-crowdsource",
        },
        "question": {
            "original": old["question"],
            "normalized": old["normalized-question"],
        },
        "answers": {
            "raw": raw,
            "clusters": clusters,
        },
        "num": {"answers": num_answers, "clusters": len(clusters)},
    }
    return new