Beispiel #1
0
def t2t_bleu(targets, predictions):
  """Tokenizes with the bleu_tokenize method from the t2t library then
  calls the compute_bleu function

  Args:
    targets: a list of strings, the target from the validation set
    preditcions: a list of strings, the model predictions

  Returns:
    a dictionary: {"t2t_bleu": bleu_value}
  """
  targets_tokens = [bleu_hook.bleu_tokenize(x) for x in targets]
  predictions_tokens = [bleu_hook.bleu_tokenize(x) for x in predictions]
  return {"t2t_bleu": 100 * bleu_hook.compute_bleu(targets_tokens,
                                                   predictions_tokens)}
 def testBleuTokenize(self):
   self.assertEqual(bleu_hook.bleu_tokenize(u"hi, “there”"),
                    [u"hi", u",", u"“", u"there", u"”"])
 def testBleuTokenize(self):
     self.assertEqual(bleu_hook.bleu_tokenize(u"hi, “there”"),
                      [u"hi", u",", u"“", u"there", u"”"])
Beispiel #4
0
 def testBleuTokenize(self):
   self.assertEqual(bleu_hook.bleu_tokenize(u'hi, “there”'), [u'hi', u',', u'“', u'there', u'”'])