def get_raw_scores(dataset, preds, tag_preds, root_dir):
    r"""
    Calculate all the three matrix (exact match, f1, POS) for each question.

    Arguments:
        dataset (dict): the dataset in use.
        preds (dict): the answer text prediction for each question in the dataset.
        tag_preds (dict): the answer tags prediction for each question in the dataset.
        root_dir (str): the base directory for the html files.

    Returns:
        tuple(dict, dict, dict): exact match, f1, pos scores for each question.
    """
    exact_scores = {}
    f1_scores = {}
    pos_scores = {}
    for websites in dataset:
        for w in websites['websites']:
            f = os.path.join(root_dir, websites['domain'], w['page_id'][0:2], 'processed_data',
                             w['page_id'] + '.html')
            for qa in w['qas']:
                qid = qa['id']
                gold_answers = [a['text'] for a in qa['answers']
                                if normalize_answer(a['text'])]
                gold_tag_answers = [a['element_id'] for a in qa['answers']]
                additional_tag_information = [a['answer_start'] for a in qa['answers']]
                if not gold_answers:
                    # For unanswerable questions, only correct answer is empty string
                    gold_answers = ['']
                if qid not in preds:
                    print('Missing prediction for %s' % qid)
                    continue
                a_pred, t_pred = preds[qid], tag_preds[qid]
                # Take max over all gold answers
                exact_scores[qid] = max(compute_exact(a, a_pred) for a in gold_answers)
                f1_scores[qid] = max(compute_f1(a, a_pred) for a in gold_answers)
                pos_scores[qid] = max(compute_pos(f, t, a, t_pred)
                                      for t, a in zip(gold_tag_answers, additional_tag_information))
    return exact_scores, f1_scores, pos_scores

    Calculate all the three matrix (exact match, f1, POS) for each question.

    Arguments:
        dataset (dict): the dataset in use.
        preds (dict): the answer text prediction for each question in the dataset.
        tag_preds (dict): the answer tags prediction for each question in the dataset.
        root_dir (str): the base directory for the html files.

    Returns:
        tuple(dict, dict, dict): exact match, f1, pos scores for each question.
    
markuplm/examples/fine_tuning/run_websrc/utils_evaluate.py