Commit f7a3cf20 authored by lintangsutawika's avatar lintangsutawika
Browse files

adjust mathqa

parent a83874e5
...@@ -9,7 +9,7 @@ validation_split: validation ...@@ -9,7 +9,7 @@ validation_split: validation
test_split: test test_split: test
doc_to_text: "Question: {{Problem}}\nAnswer:" doc_to_text: "Question: {{Problem}}\nAnswer:"
doc_to_target: !function utils.doc_to_target doc_to_target: !function utils.doc_to_target
create_choices: !function utils.create_choices # create list of answer choices doc_to_choice: !function utils.doc_to_choice # create list of answer choices
metric_list: metric_list:
- metric: acc - metric: acc
aggregation: mean aggregation: mean
......
import re import re
def create_choices(doc): def doc_to_choice(doc):
choices = [ choices = [
c[4:].rstrip(" ,") c[4:].rstrip(" ,")
for c in re.findall(r"[abcd] \) .*?, |e \) .*?$", doc["options"]) for c in re.findall(r"[abcd] \) .*?, |e \) .*?$", doc["options"])
...@@ -10,5 +10,5 @@ def create_choices(doc): ...@@ -10,5 +10,5 @@ def create_choices(doc):
def doc_to_target(doc): def doc_to_target(doc):
choices = create_choices(doc) choices = doc_to_choice(doc)
return choices[["a", "b", "c", "d", "e"].index(doc["correct"])] return choices[["a", "b", "c", "d", "e"].index(doc["correct"])]
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