deeppavlov/metrics/squad_metrics.py
def squad_v2_exact_match(y_true: List[List[str]], y_predicted: List[str]) -> float:
    """ Calculates Exact Match score between y_true and y_predicted
        EM score uses the best matching y_true answer:
            if y_pred equal at least to one answer in y_true then EM = 1, else EM = 0

    The same as in SQuAD-v2.0

    Args:
        y_true: list of correct answers (correct answers are represented by list of strings)
        y_predicted: list of predicted answers

    Returns:
        exact match score : float
    """
    EM_total = sum(normalize_answer(prediction) in map(normalize_answer, ground_truth)
                   for ground_truth, prediction in zip(y_true, y_predicted))
    return 100 * EM_total / len(y_true) if len(y_true) > 0 else 0
def squad_v2_exact_match(y_true: List[List[str]], y_predicted: List[str]) -> float:
    """ Calculates Exact Match score between y_true and y_predicted
        EM score uses the best matching y_true answer:
            if y_pred equal at least to one answer in y_true then EM = 1, else EM = 0

    The same as in SQuAD-v2.0

    Args:
        y_true: list of correct answers (correct answers are represented by list of strings)
        y_predicted: list of predicted answers

    Returns:
        exact match score : float
    """
    EM_total = sum(normalize_answer(prediction) in map(normalize_answer, ground_truth)
                   for ground_truth, prediction in zip(y_true, y_predicted))
    return 100 * EM_total / len(y_true) if len(y_true) > 0 else 0
Calculates Exact Match score between y_true and y_predicted
        EM score uses the best matching y_true answer:
            if y_pred equal at least to one answer in y_true then EM = 1, else EM = 0

    The same as in SQuAD-v2.0

    Args:
        y_true: list of correct answers (correct answers are represented by list of strings)
        y_predicted: list of predicted answers

    Returns:
        exact match score : float