Skip to content

Commit

Permalink
fix SacrebleuScorer.score()
Browse files Browse the repository at this point in the history
Summary: fix SacrebleuScorer.score()

Reviewed By: sravyapopuri388

Differential Revision: D33311843

fbshipit-source-id: 8536baceab6ef2e7c9c4a9a8a005abaa6a9229f0
  • Loading branch information
kahne authored and mgaido91 committed Feb 22, 2024
1 parent 901a143 commit e1e04bb
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions fairseq/scoring/bleu.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,17 @@ def add_string(self, ref, pred):
self.ref.append(self.tokenizer.tokenize(ref))
self.pred.append(self.tokenizer.tokenize(pred))

def score(self, order=4):
return self.result_string(order).score

def result_string(self, order=4):
def _score(self, order=4):
if order != 4:
raise NotImplementedError
# tokenization and lowercasing are performed by self.tokenizer instead.
return self.sacrebleu.corpus_bleu(
self.pred, [self.ref], tokenize="none"
).format()
return self.sacrebleu.corpus_bleu(self.pred, [self.ref], tokenize="none")

def score(self, order=4):
return self._score(order).score

def result_string(self, order=4):
return self._score(order).format()


@dataclass
Expand Down

0 comments on commit e1e04bb

Please sign in to comment.