Example #1
0
 def score(self, hyps, refs, lang=None, check_tok=True):
     """Score a list of hypotheses"""
     if len(hyps) != len(refs):
         raise ValueError("Mismatched input lengths "
                          f"{len(hyps)}!={len(refs)}")
     if check_tok:
         utils.check_tokenization(hyps)
         utils.check_tokenization(refs)
     return self.score_corpus(hyps, refs, lang=lang)
Example #2
0
 def rd_score(self, hyps, bases, refs, lang=None, check_tok=True):
     """Relative decrease in score"""
     if check_tok:
         utils.check_tokenization(hyps)
         utils.check_tokenization(bases)
         utils.check_tokenization(refs)
     base_scores = self.score(bases, refs, lang=lang, check_tok=False)
     hyp_scores = self.score(hyps, refs, lang=lang, check_tok=False)
     rd_scores = [
         utils.relative_decrease(base_score, hyp_score)
         for base_score, hyp_score in zip(base_scores, hyp_scores)
     ]
     return rd_scores