def ngrams(text, n):
    words = text.lower().split()
    return [tuple(words[i:i+n]) for i in range(len(words)-n+1)]

print(ngrams("the quick brown fox jumps", 2))



BIGRAM
def ngrams(text, n):
    words = text.lower().split()
    return [tuple(words[i:i+n]) for i in range(len(words)-n+1)]

print(ngrams("the quick brown fox jumps over the lazy dog", 2))

###
from nltk.util import ngrams

text = "natural language processing"

words = text.lower().split()

# Bigrams
bigrams = list(ngrams(words, 2))
print("Bigrams:", bigrams)


from nltk.util import ngrams

text = "natural language processing"
# Trigrams
trigrams = list(ngrams(words, 3))
print("Trigrams:", trigrams)