utils.py 307 Bytes
Newer Older
haileyschoelkopf's avatar
haileyschoelkopf committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import re


def create_choices(doc):
    choices = [
        c[4:].rstrip(" ,")
        for c in re.findall(r"[abcd] \) .*?, |e \) .*?$", doc["options"])
    ]
    return choices


def doc_to_target(doc):
    choices = create_choices(doc)
    return choices[["a", "b", "c", "d", "e"].index(doc["correct"])]