Example #1
0
 def testMatchingSentences(self):
     """If input=output=reference, the score should be 1."""
     input_sentence = [3, 1, 4, 1, 5, 9, 2, 6, 5]
     output = input_sentence
     references = [input_sentence]
     score, _, _, _ = sari_hook.get_sari_score(input_sentence, output,
                                               references)
     self.assertEqual(1, score)
Example #2
0
 def testMatchingOutputAndReference(self):
     """If output=reference, the score should be 1."""
     input_sentence = [3, 1, 4, 1, 5, 9, 2, 6, 5]
     output = [3, 1, 4, 1, 80, 70]
     references = [output]
     score, _, _, _ = sari_hook.get_sari_score(input_sentence, output,
                                               references)
     self.assertEqual(1, score)
Example #3
0
 def testIdsWithZeros(self):
     """Zeros should be ignored."""
     input_sentence = [3, 1, 4, 0, 0, 0]
     output = [3, 1, 4]
     references = [[3, 1, 4, 0, 0, 0, 0, 0]]
     score, _, _, _ = sari_hook.get_sari_score(input_sentence, output,
                                               references)
     self.assertEqual(1, score)
Example #4
0
 def testMatchingSentencesWithRepetitions(self):
   """Token frequencies should not matter if we only consider unigrams."""
   input_sentence = [3, 1, 4]
   output = [3, 3, 1, 1, 1, 4]
   references = [[3, 3, 3, 1, 1, 4, 4]]
   score, _, _, _ = sari_hook.get_sari_score(input_sentence, output,
                                             references, max_gram_size=1)
   self.assertEqual(1, score)
Example #5
0
    def testSariSent1(self):
        """Test case 1 from SARI-paper.

    The score is slightly different from what is reported in the paper (0.2683)
    since the authors' code seems to contain a bug in the keep recall score
    computation.
    """
        output = "About 95 you now get in .".split()
        score, _, _, _ = sari_hook.get_sari_score(self.input_sentence, output,
                                                  self.references)
        self.assertAlmostEqual(0.2695360, score)
Example #6
0
 def testSariSent3(self):
     """Test case 3 from SARI-paper."""
     output = "About 95 species are currently agreed .".split()
     score, _, _, _ = sari_hook.get_sari_score(self.input_sentence, output,
                                               self.references)
     self.assertAlmostEqual(0.5088682, score)
Example #7
0
 def testSariSent2(self):
     """Test case 2 from SARI-paper."""
     output = "About 95 species are now agreed .".split()
     score, _, _, _ = sari_hook.get_sari_score(self.input_sentence, output,
                                               self.references)
     self.assertAlmostEqual(0.6170966, score)