preprocess_winogrande.py 412 Bytes
Newer Older
1
def doc_to_target(doc) -> int:
lintangsutawika's avatar
lintangsutawika committed
2
3
    answer_to_num = {"1": 0, "2": 1}
    return answer_to_num[doc["answer"]]
lintangsutawika's avatar
lintangsutawika committed
4

5

6
def doc_to_choice(doc) -> list[str]:
7
    idx = doc["sentence"].index("_") + 1
8
    return [doc["sentence"][idx:].strip()]
9

Benjamin Fattori's avatar
Benjamin Fattori committed
10

11
def doc_to_text(doc) -> list[str]:
lintangsutawika's avatar
lintangsutawika committed
12
13
14
    idx = doc["sentence"].index("_")
    options = [doc["option1"], doc["option2"]]
    return [doc["sentence"][:idx] + opt for opt in options]