I have a list of sentences:
text = [\'cant railway station\',\'citadel hotel\',\' police stn\'].
I need to form bigram pairs and store the
Using list comprehensions and zip:
>>> text = ["this is a sentence", "so is this one"] >>> bigrams = [b for l in text for b in zip(l.split(" ")[:-1], l.split(" ")[1:])] >>> print(bigrams) [('this', 'is'), ('is', 'a'), ('a', 'sentence'), ('so', 'is'), ('is', 'this'), ('this', 'one')]