def test_pack(self): data = ["hello", "world", "it", "is", "a", "lovely", "day"] result = list(make_ngram(data, 2)) expected = [ ("hello", "world"), ("world", "it"), ("it", "is"), ("is", "a"), ("a", "lovely"), ("lovely", "day"), ] self.assertEqual(expected, result)
def main(args, _in, _out): items = _in.read().split("\n") for item in make_ngram(items, args.n): _out.write("({0})\n".format("|".join(item)))
def test_pack(self): data = ["hello", "world", "it", "is", "a", "lovely", "day"] result = list(make_ngram(data, 2)) expected = [("hello", "world"), ("world", "it"), ("it", "is"), ("is", "a"), ("a", "lovely"), ("lovely", "day")] self.assertEqual(expected, result)