def group_answers_by_answer_type()

in src/substitution_fns.py [0:0]


def group_answers_by_answer_type(dset: QADataset):
    """Reorganizes a QADataset into a mapping from answer type to member answers."""
    group_to_answer_sets = defaultdict(dict)
    for ex in dset.examples:
        for answer in ex.gold_answers:
            if answer.answer_type:
                group_to_answer_sets[answer.answer_type][answer.text] = answer
    return group_to_answer_sets