コード例 #1
0
 def testKeyPhraseF1(self):
     key_phrases = ['Google', 'Mars and Earth']
     wer_obj = simple_wer.SimpleWER(key_phrases=key_phrases)
     hyp = 'Hey Google, could you tell me a story about March and Earth?'
     ref = 'Hey Google, could you tell me a story about Mars and Earth?'
     wer_obj.AddHypRef(hyp, ref)
     stats = wer_obj.GetKeyPhraseStats()
     f1 = stats[1]
     self.assertAlmostEqual(f1, 0.66666666666666667, delta=0.01)
コード例 #2
0
 def testKeyPhraseJaccardSimilarity(self):
     key_phrases = ['Google', 'Mars and Earth']
     wer_obj = simple_wer.SimpleWER(key_phrases=key_phrases)
     hyp = 'Hey Google, could you tell me a story about March and Earth?'
     ref = 'Hey Google, could you tell me a story about Mars and Earth?'
     wer_obj.AddHypRef(hyp, ref)
     stats = wer_obj.GetKeyPhraseStats()
     jaccard = stats[0]
     self.assertEqual(jaccard, 0.5)
コード例 #3
0
 def testWerIgnoreCommentPunc(self):
     ref = '(Hello world)!    [pause] Today is a good day! How are you?'
     hyp = 'hello  world. today is a good day, how are you'
     wer_obj = simple_wer.SimpleWER()
     wer_obj.AddHypRef(hyp, ref)
     err_info = wer_obj.wer_info
     self.assertEqual(err_info['del'], 0)
     self.assertEqual(err_info['sub'], 0)
     self.assertEqual(err_info['ins'], 0)
     self.assertEqual(err_info['nw'], 10)
コード例 #4
0
    def testKeyPhraseCounts(self):
        key_phrases = ['Google', 'Mars']
        wer_obj = simple_wer.SimpleWER(key_phrases=key_phrases)

        ref = 'Hey  Google. I have a question about Mars, can I google it? '
        hyp = 'Hey Google! I have question about Mars, can I google it? '
        wer_obj.AddHypRef(hyp, ref)
        self.assertEqual(sum(wer_obj.ref_keyphrase_counts.values()), 3)
        self.assertEqual(sum(wer_obj.matched_keyphrase_counts.values()), 3)

        ref = 'Hey Google, could you tell me a story about Mars? '
        hyp = 'Hey Google, could you tell me a story about March? '
        wer_obj.AddHypRef(hyp, ref)
        self.assertEqual(sum(wer_obj.ref_keyphrase_counts.values()), 5)
        self.assertEqual(sum(wer_obj.matched_keyphrase_counts.values()), 4)