def test_valid_vary_p(self): """most_frequent should return dw most frequent words.""" for inp1, inp2 in self.DATA: prev = [] for p in range(0, 10): p = p / 10 cur = most_frequent(inp1, inp2, p, self.step, self.dw) self.assertEqual(True, len(cur) >= len(prev))
def test_valid_vary_dw(self): """most_frequent should return dw most frequent words.""" dw = [0, 1, 2, 3, 4] for inp1, inp2 in self.DATA: for d in dw: self.assertEqual(True, d <= len(most_frequent(inp1, inp2, self.p, self.step, d)))
def test_empty_freq_dict(self): """most_frequent should return empty dict on empty input freq dict.""" self.assertEqual({}, most_frequent({}, ["a"], self.p, self.step, self.dw))
def test_zero_step(self): """most_frequent will not terminate and should therefore return {}.""" step = 0 p = 0.5 DATA = ({"hi": 1, "hello": 1, "hej": 1, "hellooow": 1}, ["hi", "hello", "hej", "hellooow"]) self.assertEqual({}, most_frequent(DATA[0], DATA[1], p, step, self.dw))
def test_empty_word_list(self): """most_frequent should return empty dict on empty input word list.""" self.assertEqual({}, most_frequent({"a": 1}, [], self.p, self.step, self.dw))