コード例 #1
0
 def test_predict_next_sentence_more_words_ideal(self):
     ngram = NGramTrie(2)
     ngram.gram_log_probabilities = {
         (1, 2): -0.18,
         (1, 3): -1.79,
         (2, 3): -1,
         (2, 4): -2,
         (3, 4): -0.1,
         (3, 5): -1.8
     }
     actual_res = ngram.predict_next_sentence((1, ))
     expected_res = [1, 2, 3, 4]
     self.assertEqual(actual_res, expected_res)
コード例 #2
0
 def test_predict_next_sentence_simple_ideal(self):
     ngram = NGramTrie(2)
     ngram.gram_log_probabilities = {(1, 2): -0.18, (1, 3): -1.79}
     actual_res = ngram.predict_next_sentence((1, ))
     expected_res = [1, 2]
     self.assertEqual(actual_res, expected_res)
コード例 #3
0
 def test_predict_next_sentence_no_match(self):
     ngram = NGramTrie(2)
     ngram.gram_log_probabilities = {(4, 2): -0.18, (4, 3): -1.79}
     actual_res = ngram.predict_next_sentence((1, ))
     expected_res = [1]
     self.assertEqual(actual_res, expected_res)