Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def score_sentence(self, hyp, ref, lang=None):
return sacrebleu.sentence_bleu(hyp, ref, smooth_value=0.01) / 100
def __init__(self, metric: str,
return_score: bool = False) -> None:
if metric == C.RERANK_BLEU:
self.scoring_function = sacrebleu.sentence_bleu
elif metric == C.RERANK_CHRF:
self.scoring_function = sacrebleu.sentence_chrf
else:
raise utils.SockeyeError("Scoring metric '%s' unknown. Choices are: %s" % (metric, C.RERANK_METRICS))
self.return_score = return_score