(N=15)
| 34 | |
| 35 | |
| 36 | def test_huffman(N=15): |
| 37 | np.random.seed(12345) |
| 38 | |
| 39 | i = 0 |
| 40 | while i < N: |
| 41 | n_words = np.random.randint(1, 100) |
| 42 | para = random_paragraph(n_words) |
| 43 | HT = HuffmanEncoder() |
| 44 | HT.fit(para) |
| 45 | my_dict = HT._item2code |
| 46 | their_dict = huffman.codebook(Counter(para).items()) |
| 47 | |
| 48 | for k, v in their_dict.items(): |
| 49 | fstr = "their_dict['{}'] = {}, but my_dict['{}'] = {}" |
| 50 | assert k in my_dict, "key `{}` not in my_dict".format(k) |
| 51 | assert my_dict[k] == v, fstr.format(k, v, k, my_dict[k]) |
| 52 | print("PASSED") |
| 53 | i += 1 |
| 54 | |
| 55 | |
| 56 | def test_standardizer(N=15): |
nothing calls this directly
no test coverage detected