N-grams are used in text preprocessing tasks and they are a combination of words occur in a given window. They can consist of two combinations of words known as bi-grams,3 combinations of words known as tri-grams and so on. In a sentence X, if n is the number of words, then the number of n-grams will be
Where g=2 if bigrams, g=3 if trigrams and so on.
This is how n-gram work.