mirror of
https://github.com/CodedotAl/gpt-code-clippy.git
synced 2024-09-17 10:27:14 +03:00
18 lines
780 B
Python
18 lines
780 B
Python
from metrics.bleu import compute_bleu
|
|
|
|
def compute_metrics(references,generated) -> dict:
|
|
"""
|
|
Calculates various metrics and returns the calculated dict of these matrics.
|
|
args:
|
|
reference: list of lists of references for each translation. Each
|
|
reference should be tokenized into a list of tokens.
|
|
translation: list of translations to score. Each translation
|
|
should be tokenized into a list of tokens.
|
|
returns:
|
|
A dicitonary with different metrics intact.
|
|
"""
|
|
metrics_dict = {} #Update as in new metrics are added over here.
|
|
metrics_dict["smoothed_bleu_4"] = compute_bleu(references,generated,smooth=True)
|
|
metrics_dict["bleu_4"] = compute_bleu(references,generated,smooth=False)
|
|
|
|
return metrics_dict |