n-Grams

ɛnˈɡræmz

N-grams are contiguous sequences of n items from a given sample of text or speech. They are commonly used in natural language processing (NLP) to analyze and model the structure of language. The main characteristics of n-grams include their ability to capture contextual information and frequency patterns, which can enhance tasks such as text classification, language modeling, and machine translation. For example, a bigram (2-gram) considers pairs of consecutive words, while a trigram (3-gram) looks at triplets. N-grams are widely used in applications like search engines, predictive text input, and sentiment analysis.