Use score_multiple() to calculate precision, recall, and F1 scores (both strict and lax) across multiple pairs of alignment files.
Input Formats:
gold_list: A list of alignment sets (the ground truth).test_list: A list of alignment sets (the predicted alignments).- Each alignment set should be a list of tuples, where each tuple contains two collections of indices (e.g.,
[( (src_idx1, src_idx2), (tgt_idx1,) ), ... ]).
Output Format:
A dictionary containing the following keys:
precision_strict: Precision based on exact matches.precision_lax: Precision based on partial overlaps.recall_strict: Recall based on exact matches.recall_lax: Recall based on partial overlaps.f1_strict: F1 score for strict matching.f1_lax: F1 score for lax matching.
If a denominator is zero, the score defaults to the value_for_div_by_0 parameter (default is 0.0).
from vecalign.score import score_multiple
# Example alignment data
gold_alignments = [((0, 1), (0,)), ((2,), (1, 2))]
test_alignments = [((0,), (0,)), ((2,), (1,))]
results = score_multiple(gold_list=[gold_alignments], test_list=[test_alignments])
print(results)
# Output: {'recall_strict': ..., 'recall_lax': ..., 'precision_strict': ..., 'precision_lax': ..., 'f1_strict': ..., 'f1_lax': ...}