Ejemplo n.º 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)
Ejemplo n.º 2
0
 def test_predict_next_sentence_wrong_size(self):
     ngram = NGramTrie(2)
     actual_res = ngram.predict_next_sentence((1, 2))
     expected_res = []
     self.assertEqual(actual_res, expected_res)
Ejemplo n.º 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)
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
 def test_predict_next_sentence_not_a_tuple(self):
     ngram = NGramTrie(2)
     actual_res = ngram.predict_next_sentence([1])
     expected_res = []
     self.assertEqual(actual_res, expected_res)