N-gram
A sequence of N consecutive text elements: words or characters.
Examples
For the phrase "the cat sits quietly":
- unigrams (1-gram): "the", "cat", "sits", "quietly";
- bigrams (2-gram): "the cat", "cat sits", "sits quietly";
- trigrams (3-gram): "the cat sits", "cat sits quietly".
Why
N-grams account for context that a bag of words lacks. They are used in search, BLEU, and language models.