"IMG/cpio/vscode:/vscode.git/clone" did not exist on "096cc99c3c0467be99781aa61f9fc46e0000dbaf"
Commit c74e2761 authored by lintangsutawika's avatar lintangsutawika
Browse files

reformat

parent cc572624
include: ../_mathqa_alt_yaml include: ../_mathqa_alt_yaml
group: mathqa_06 group: mathqa_06
group_alias: style_06 group_alias: style_06
task: mathqa_06b task: mathqa_06b
task_alias: b task_alias: b
doc_to_text: !function ../styles.template_06 doc_to_text: !function ../styles.template_06
doc_to_choice: !function ../styles.choice_06b doc_to_choice: !function ../styles.choice_06b
\ No newline at end of file
include: ../_mathqa_alt_yaml include: ../_mathqa_alt_yaml
group: mathqa_06 group: mathqa_06
group_alias: style_06 group_alias: style_06
task: mathqa_06c task: mathqa_06c
task_alias: c task_alias: c
doc_to_text: !function ../styles.template_06 doc_to_text: !function ../styles.template_06
doc_to_choice: !function ../styles.choice_06c doc_to_choice: !function ../styles.choice_06c
\ No newline at end of file
include: ../_mathqa_alt_yaml include: ../_mathqa_alt_yaml
group: mathqa_07 group: mathqa_07
group_alias: style_07 group_alias: style_07
task: mathqa_07a task: mathqa_07a
task_alias: a task_alias: a
doc_to_text: !function ../styles.template_07 doc_to_text: !function ../styles.template_07
doc_to_choice: !function ../styles.choice_07a doc_to_choice: !function ../styles.choice_07a
\ No newline at end of file
include: ../_mathqa_alt_yaml include: ../_mathqa_alt_yaml
group: mathqa_07 group: mathqa_07
group_alias: style_07 group_alias: style_07
task: mathqa_07b task: mathqa_07b
task_alias: b task_alias: b
doc_to_text: !function ../styles.template_07 doc_to_text: !function ../styles.template_07
doc_to_choice: !function ../styles.choice_07b doc_to_choice: !function ../styles.choice_07b
\ No newline at end of file
include: ../_mathqa_alt_yaml include: ../_mathqa_alt_yaml
group: mathqa_07 group: mathqa_07
group_alias: style_07 group_alias: style_07
task: mathqa_07c task: mathqa_07c
task_alias: c task_alias: c
doc_to_text: !function ../styles.template_07 doc_to_text: !function ../styles.template_07
doc_to_choice: !function ../styles.choice_07c doc_to_choice: !function ../styles.choice_07c
\ No newline at end of file
include: ../_mathqa_alt_yaml include: ../_mathqa_alt_yaml
group: mathqa_08 group: mathqa_08
group_alias: style_08 group_alias: style_08
task: mathqa_08a task: mathqa_08a
task_alias: a task_alias: a
doc_to_text: !function ../styles.template_08 doc_to_text: !function ../styles.template_08
doc_to_choice: !function ../styles.choice_08a doc_to_choice: !function ../styles.choice_08a
\ No newline at end of file
include: ../_mathqa_alt_yaml include: ../_mathqa_alt_yaml
group: mathqa_08 group: mathqa_08
group_alias: style_08 group_alias: style_08
task: mathqa_08b task: mathqa_08b
task_alias: b task_alias: b
doc_to_text: !function ../styles.template_08 doc_to_text: !function ../styles.template_08
doc_to_choice: !function ../styles.choice_08b doc_to_choice: !function ../styles.choice_08b
\ No newline at end of file
include: ../_mathqa_alt_yaml include: ../_mathqa_alt_yaml
group: mathqa_08 group: mathqa_08
group_alias: style_08 group_alias: style_08
task: mathqa_08c task: mathqa_08c
task_alias: c task_alias: c
doc_to_text: !function ../styles.template_08 doc_to_text: !function ../styles.template_08
doc_to_choice: !function ../styles.choice_08c doc_to_choice: !function ../styles.choice_08c
\ No newline at end of file
...@@ -2,6 +2,7 @@ import re ...@@ -2,6 +2,7 @@ import re
import string import string
from functools import partial from functools import partial
def parse_choices(doc): def parse_choices(doc):
choices = [ choices = [
c[4:].rstrip(" ,") c[4:].rstrip(" ,")
...@@ -9,6 +10,7 @@ def parse_choices(doc): ...@@ -9,6 +10,7 @@ def parse_choices(doc):
] ]
return choices return choices
def doc_to_text_base(alphabet, style, doc): def doc_to_text_base(alphabet, style, doc):
choices = parse_choices(doc) choices = parse_choices(doc)
...@@ -22,17 +24,18 @@ def doc_to_text_base(alphabet, style, doc): ...@@ -22,17 +24,18 @@ def doc_to_text_base(alphabet, style, doc):
else: else:
choice_string = "{} {}" choice_string = "{} {}"
doc_to_text = "\n\n".join( doc_to_text = "\n\n".join(
[doc["Problem"]] + [ [doc["Problem"]]
choice_string.format(i,j) for i,j in zip(letter_list, choices) + [choice_string.format(i, j) for i, j in zip(letter_list, choices)]
]
) )
return doc_to_text return doc_to_text
# Full continuation # Full continuation
def choice_A(doc): def choice_A(doc):
return parse_choices(doc) return parse_choices(doc)
# Letters only # Letters only
def choice_B(alphabet, style, doc): def choice_B(alphabet, style, doc):
...@@ -41,10 +44,11 @@ def choice_B(alphabet, style, doc): ...@@ -41,10 +44,11 @@ def choice_B(alphabet, style, doc):
letter_list = [style.format(letter) for letter in alphabet[0:num]] letter_list = [style.format(letter) for letter in alphabet[0:num]]
if "\t" in style: if "\t" in style:
letter_list = [letter.replace("\t","") for letter in letter_list] letter_list = [letter.replace("\t", "") for letter in letter_list]
return letter_list return letter_list
# Letters + Full continuation # Letters + Full continuation
def choice_C(alphabet, style, doc): def choice_C(alphabet, style, doc):
...@@ -53,9 +57,10 @@ def choice_C(alphabet, style, doc): ...@@ -53,9 +57,10 @@ def choice_C(alphabet, style, doc):
letter_list = [style.format(letter) for letter in alphabet[0:num]] letter_list = [style.format(letter) for letter in alphabet[0:num]]
if "\t" not in style: if "\t" not in style:
letter_list = [letter+" " for letter in letter_list] letter_list = [letter + " " for letter in letter_list]
return [letter + choice for letter, choice in zip(letter_list, choices)]
return [letter+choice for letter, choice in zip(letter_list, choices)]
template_01 = partial(doc_to_text_base, string.ascii_lowercase, "({})") template_01 = partial(doc_to_text_base, string.ascii_lowercase, "({})")
choice_01a = choice_A choice_01a = choice_A
...@@ -89,5 +94,3 @@ template_08 = partial(doc_to_text_base, string.ascii_uppercase, "{}\t") ...@@ -89,5 +94,3 @@ template_08 = partial(doc_to_text_base, string.ascii_uppercase, "{}\t")
choice_08a = choice_A choice_08a = choice_A
choice_08b = partial(choice_B, string.ascii_uppercase, "{}\t") choice_08b = partial(choice_B, string.ascii_uppercase, "{}\t")
choice_08c = partial(choice_C, string.ascii_uppercase, "{}\t") choice_08c = partial(choice_C, string.ascii_uppercase, "{}\t")
...@@ -4,4 +4,4 @@ task: ...@@ -4,4 +4,4 @@ task:
- mmlu_style_02_fc - mmlu_style_02_fc
- mmlu_style_03_fc - mmlu_style_03_fc
- mmlu_style_04_fc - mmlu_style_04_fc
- mmlu_style_05_fc - mmlu_style_05_fc
\ No newline at end of file
...@@ -4,4 +4,4 @@ task: ...@@ -4,4 +4,4 @@ task:
- mmlu_style_02_lo - mmlu_style_02_lo
- mmlu_style_03_lo - mmlu_style_03_lo
- mmlu_style_04_lo - mmlu_style_04_lo
- mmlu_style_05_lo - mmlu_style_05_lo
\ No newline at end of file
group: mmlu_style_01 group: mmlu_style_01
group_alias: style_01 group_alias: style_01
task: mmlu_style_01a task: mmlu_style_01a
task_alias: a task_alias: a
dataset_path: cais/mmlu dataset_path: cais/mmlu
......
group: mmlu_style_01 group: mmlu_style_01
group_alias: style_01 group_alias: style_01
task: mmlu_style_01b task: mmlu_style_01b
task_alias: b task_alias: b
dataset_path: cais/mmlu dataset_path: cais/mmlu
......
group: mmlu_style_01 group: mmlu_style_01
group_alias: style_01 group_alias: style_01
task: mmlu_style_01c task: mmlu_style_01c
task_alias: c task_alias: c
dataset_path: cais/mmlu dataset_path: cais/mmlu
......
import string import string
from functools import partial from functools import partial
def doc_to_text_base(alphabet, style, doc): def doc_to_text_base(alphabet, style, doc):
choices = doc["choices"]["text"] choices = doc["choices"]["text"]
...@@ -13,19 +14,21 @@ def doc_to_text_base(alphabet, style, doc): ...@@ -13,19 +14,21 @@ def doc_to_text_base(alphabet, style, doc):
else: else:
choice_string = "{} {}" choice_string = "{} {}"
doc_to_text = "\n\n".join([ doc_to_text = "\n\n".join(
"Question: "+doc["question"].strip()+"\nAnswer:", [
] + [ "Question: " + doc["question"].strip() + "\nAnswer:",
choice_string.format(i,j) for i,j in zip(letter_list, choices)
] ]
+ [choice_string.format(i, j) for i, j in zip(letter_list, choices)]
) )
return doc_to_text return doc_to_text
# Full continuation # Full continuation
def choice_A(doc): def choice_A(doc):
return doc["choices"]["text"] return doc["choices"]["text"]
# Letters only # Letters only
def choice_B(alphabet, style, doc): def choice_B(alphabet, style, doc):
...@@ -34,10 +37,11 @@ def choice_B(alphabet, style, doc): ...@@ -34,10 +37,11 @@ def choice_B(alphabet, style, doc):
letter_list = [style.format(letter) for letter in alphabet[0:num]] letter_list = [style.format(letter) for letter in alphabet[0:num]]
if "\t" in style: if "\t" in style:
letter_list = [letter.replace("\t","") for letter in letter_list] letter_list = [letter.replace("\t", "") for letter in letter_list]
return letter_list return letter_list
# Letters + Full continuation # Letters + Full continuation
def choice_C(alphabet, style, doc): def choice_C(alphabet, style, doc):
...@@ -46,9 +50,10 @@ def choice_C(alphabet, style, doc): ...@@ -46,9 +50,10 @@ def choice_C(alphabet, style, doc):
letter_list = [style.format(letter) for letter in alphabet[0:num]] letter_list = [style.format(letter) for letter in alphabet[0:num]]
if "\t" not in style: if "\t" not in style:
letter_list = [letter+" " for letter in letter_list] letter_list = [letter + " " for letter in letter_list]
return [letter + choice for letter, choice in zip(letter_list, choices)]
return [letter+choice for letter, choice in zip(letter_list, choices)]
template_01 = partial(doc_to_text_base, string.ascii_lowercase, "({})") template_01 = partial(doc_to_text_base, string.ascii_lowercase, "({})")
choice_01a = choice_A choice_01a = choice_A
...@@ -82,5 +87,3 @@ template_08 = partial(doc_to_text_base, string.ascii_uppercase, "{}\t") ...@@ -82,5 +87,3 @@ template_08 = partial(doc_to_text_base, string.ascii_uppercase, "{}\t")
choice_08a = choice_A choice_08a = choice_A
choice_08b = partial(choice_B, string.ascii_uppercase, "{}\t") choice_08b = partial(choice_B, string.ascii_uppercase, "{}\t")
choice_08c = partial(choice_C, string.ascii_uppercase, "{}\t") choice_08c = partial(choice_C, string.ascii_uppercase, "{}\t")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment