def _get_ngrams(n, text):
    'Calculates n-grams.\n\n  Args:\n    n: which n-grams to calculate\n    text: An array of tokens\n\n  Returns:\n    A set of n-grams\n  '
    ngram_set = set()
    text_length = len(text)
    max_index_ngram_start = (text_length - n)
    for i in range((max_index_ngram_start + 1)):
        ngram_set.add(tuple(text[i:(i + n)]))
    return ngram_set
Calculates n-grams.

Args:
  n: which n-grams to calculate
  text: An array of tokens

Returns:
  A set of n-grams
def _get_ngrams(n, text):
    'Calculates n-grams.\n\n  Args:\n    n: which n-grams to calculate\n    text: An array of tokens\n\n  Returns:\n    A set of n-grams\n  '
    ngram_set = set()
    text_length = len(text)
    max_index_ngram_start = (text_length - n)
    for i in range((max_index_ngram_start + 1)):
        ngram_set.add(tuple(text[i:(i + n)]))
    return ngram_set