The ML.NGRAMS function

This document describes the ML.NGRAMS function, which lets you create n-grams of the input values.

Syntax

ML.NGRAMS(array_input, range [, separator])

Arguments

ML.NGRAMS takes the following arguments:

Output

ML.NGRAMS returns an ARRAY<STRING> value that contain the n-grams.

Example

The following example outputs all possible 2-token and 3-token combinations for a set of three input strings:

SELECT
  ML.NGRAMS(['a', 'b', 'c'], [2,3], '#') AS output;

The output looks similar to the following:

+-----------------------+
|        output         |
+-----------------------+
| ["a#b","a#b#c","b#c"] |
+-----------------------+

What's next