-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_vb_alg.py
34 lines (26 loc) · 1.29 KB
/
test_vb_alg.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import unittest
from ViterbiAlgorithm import viterbi_segment
from words_check_by_levenshtein import LevenshteinWordCheck
class MyTestCase(unittest.TestCase):
def test_long_string(self):
text = "яидупополю"
checker = LevenshteinWordCheck(key=lambda item: item.distance)
self.assertEqual(viterbi_segment(text, checker), ['я', 'иду', 'по', 'полю'])
def test_one_word(self):
text = "молоко"
checker = LevenshteinWordCheck(key=lambda item: item.distance)
self.assertEqual(viterbi_segment(text, checker), ['молоко'])
def test_two_words1(self):
text = "вполе"
checker = LevenshteinWordCheck(key=lambda item: item.distance)
self.assertEqual(viterbi_segment(text, checker), ['в', 'поле'])
def test_string_with_repeating(self):
text = "яяиду"
checker = LevenshteinWordCheck(key=lambda item: item.distance)
self.assertEqual(viterbi_segment(text, checker), ['я', 'я', 'иду'])
def test_string_with_two_words2(self):
text = "котсобака"
checker = LevenshteinWordCheck(key=lambda item: item.distance)
self.assertEqual(viterbi_segment(text, checker), ['кот', 'собака'])
if __name__ == '__main__':
unittest.main()