createNGrams method

List<NGram<T>> createNGrams(
  1. int n
)

Creates all n-grams of size n from this token list.

Implementation

List<NGram<T>> createNGrams(int n) {
  if (n <= 0 || length < n) return [];
  return [
    for (var i = 0; i <= length - n; i++) NGram<T>(sublist(i, i + n)),
  ];
}