Skip to content

squad

allennlp_models.rc.tools.squad

[SOURCE]


Functions taken from the official evaluation script for SQuAD version 2.0.

make_qid_to_has_ans#

def make_qid_to_has_ans(dataset)

normalize_answer#

def normalize_answer(s)

Lower text and remove punctuation, articles and extra whitespace.

get_tokens#

def get_tokens(s)

compute_exact#

def compute_exact(a_gold, a_pred)

compute_f1#

def compute_f1(a_gold, a_pred)

metric_max_over_ground_truths#

def metric_max_over_ground_truths(
    metric_fn,
    prediction,
    ground_truths
)

get_metric_score#

def get_metric_score(prediction, gold_answers)