def test_base_case(self): text = ' '.join(chain(['a'] * 5, ['b'] * 5, ['c'] * 5, ['d'] * 2, ['e'] * 2)) self.assertEqual('A b c.', summarize_text(text, n_common_words=3))
sys.exit() try: if task_num == 1: if path: text = open_as_text(path) else: text = data word_counts = word_count(text) print_word_count_result(word_counts) elif task_num == 2: if path: text = open_as_text(path) else: text = data sentence = summarize_text(text) print(sentence) elif task_num == 3: if path: nums = open_as_list_of_ints(path) else: nums = [int(s_i) for s_i in data.split(' ')] sorted_nums = quick_sort(nums) print_list_of_ints(sorted_nums) elif task_num == 4: if path: nums = open_as_list_of_ints(path) else: nums = [int(s_i) for s_i in data.split(' ')] sorted_nums = merge_sort(nums) print_list_of_ints(sorted_nums)