Our newest machine learning developer want to write a function to calculate the n-gram of any text. An N-gram means a sequence of N words. So for example, "black cats" is a 2-gram, "saw black cats" is a 3-gram etc. The 2-gram of the sentence "the big bad wolf fell down" would be [["the", "big"], ["big", "bad"], ["bad", "wolf"], ["wolf", "fell"], ["fell", "down"]]. Can you help them select the correct function for the same?
n-gram generator image