def test_fill_from_sentence_none(self): ngram = NGramTrie(2) sentence = None res = ngram.fill_from_sentence(sentence) print(res) expected_res = {} self.assertEqual(ngram.gram_frequencies, expected_res)
def test_fill_from_sentence_not_tuple(self): ngram = NGramTrie(2) sentence = [1, 2, 3, 4, 5] ngram.fill_from_sentence(sentence) expected_res = {} self.assertEqual(ngram.gram_frequencies, expected_res)
def test_fill_from_sentence_duplcicates_ideal(self): ngram = NGramTrie(2) sentence = (1, 2, 1, 2, 1, 2) ngram.fill_from_sentence(sentence) expected_res = {(1, 2): 3, (2, 1): 2} self.assertEqual(ngram.gram_frequencies, expected_res)
def test_fill_from_sentence_empty(self): ngram = NGramTrie(2) sentence = () ngram.fill_from_sentence(sentence) expected_res = {} self.assertEqual(ngram.gram_frequencies, expected_res)
def test_fill_from_sentence_ideal(self): ngram = NGramTrie(2) sentence = (1, 2, 3, 4, 5) ngram.fill_from_sentence(sentence) expected_res = {(1, 2): 1, (2, 3): 1, (3, 4): 1, (4, 5): 1} self.assertEqual(ngram.gram_frequencies, expected_res)