"src/include/blockwise_2d_tensor_op.hpp" did not exist on "17f3d2d4bccebcc3a70606a916f93dc90e5eaa3a"
Commit f7dde0c3 authored by lintangsutawika's avatar lintangsutawika
Browse files

formatted

parent 7684bfa9
......@@ -4,13 +4,11 @@ def doc_to_text(doc):
ctxs, doc["question"], doc["final_decision"]
)
def doc_to_target(doc):
return " {}".format(doc["final_decision"])
def gold_alias(doc):
dict_to_label = {
'yes': 0,
'no': 1,
'maybe': 2
}
return dict_to_label[doc["final_decision"]]
\ No newline at end of file
dict_to_label = {"yes": 0, "no": 1, "maybe": 2}
return dict_to_label[doc["final_decision"]]
......@@ -14,4 +14,4 @@ gold_alias: !function preprocess_pubmedqa.gold_alias
metric_list:
- metric: acc
aggregation: mean
higher_is_better: true
\ No newline at end of file
higher_is_better: true
import ast
import ast
def process_ast(string):
return ast.literal_eval(string)
def last_problem(doc):
return process_ast(doc["problems"])[-1]
def get_answer_option(problem):
letter_to_num = {"A": 0, "B": 1, "C": 2, "D": 3}
answer = letter_to_num[problem["answer"]]
return problem["options"][answer]
def create_choices(doc):
problem = last_problem(doc)
choices = [problem["options"][i] for i in range(4)]
return choices
def doc_to_text(doc):
text = "Article: " + doc["article"] + "\n\n"
for problem in process_ast(doc["problems"])[:-1]:
if problem["question"][-6:] == " _ .":
text += (
problem["question"][-5:] + get_answer_option(problem) + "\n"
)
text += problem["question"][-5:] + get_answer_option(problem) + "\n"
else:
question = "Question: " + problem["question"] + "\n"
answer = "Answer: " + get_answer_option(problem) + "\n"
......@@ -30,6 +33,7 @@ def doc_to_text(doc):
text += last_problem(doc)["question"]
return text
def doc_to_target(doc):
letter_to_num = {"A": 0, "B": 1, "C": 2, "D": 3}
answer = letter_to_num[last_problem(doc)["answer"]]
......
......@@ -17,4 +17,4 @@ metric_list:
higher_is_better: true
- metric: acc_norm
aggregation: mean
higher_is_better: true
\ No newline at end of file
higher_is_better: true
......@@ -4,11 +4,13 @@ def partial_context(doc, option):
pronoun_loc = doc["sentence"].index("_")
return doc["sentence"][:pronoun_loc] + option
def partial_target(doc):
# The target is everything after the document specified pronoun.
pronoun_loc = doc["sentence"].index("_") + 1
return doc["sentence"][pronoun_loc:].strip()
def create_choices(doc):
choices = []
for option in [doc["option1"], doc["option2"]]:
......@@ -16,6 +18,7 @@ def create_choices(doc):
choices.append(partial_ctx)
return choices
def gold_alias(doc):
answer_to_num = {"1": 0, "2": 1}
return answer_to_num[doc['answer']]
\ No newline at end of file
return answer_to_num[doc["answer"]]
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