Beispiel #1
0
 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)
Beispiel #2
0
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)))
Beispiel #3
0
 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)
Beispiel #4
0
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)))