An n-gram is a sliding window of n consecutive characters. Matching on
character n-grams instead of whole words tolerates typos, truncations, and
joined-up spellings, because two strings that differ by a letter still share
most of their windows ("meier" and "maier" share "ei", "er", and so
on). Reach for it on short, noisy fields where word tokens are too brittle.
Value
A list of character vectors, one per input element. Strings shorter
than n yield an empty vector.
Details
It tokenizes text directly, so it replaces word_tokens() rather than
following it. The trade-off is fan-out: every string yields many overlapping
tokens, so n-grams cost more to match than words. Larger n is sharper and
cheaper, smaller n is fuzzier and denser.
See also
word_tokens() for whole-word tokens.
Other token generators:
numeric_tokens(),
word_tokens()
