class_docstr: A class to represent a list of tokenized text.
docstr: Returns a list of all ngrams from length 1 to n.
  
  Args:
      n: upper limit of ngram length
      uncased: lower cases text
      filter_fn: user function that takes in an ngram list and returns
        True or False to keep or not keep the ngram
      as_string: return the ngram as a string vs list
docstr_tok: ["Returns","a","list","of","all","ngrams","from","length","1","to","n.","Args",":","n",":","upper","limit","of","ngram","length","uncased",":","lower","cases","text","filter_fn",":","user","function","that","takes","in","an","ngram","list","and","returns","True","or","False","to","keep","or","not","keep","the","ngram","as_string",":","return","the","ngram","as","a","string","vs","list"]
code: def ngrams(self, n=1, uncased=False, filter_fn=None, as_strings=True):
      """Returns a list of all ngrams from length 1 to n.
  
      Args:
          n: upper limit of ngram length
          uncased: lower cases text
          filter_fn: user function that takes in an ngram list and returns
            True or False to keep or not keep the ngram
          as_string: return the ngram as a string vs list
      """
  
      def _skip(gram):
          if not filter_fn:
              return False
          return filter_fn(gram)
  
      words = self.words(uncased)
      ngrams = [
          (s, e + 1)
          for s in range(len(words))
          for e in range(s, min(s + n, len(words)))
          if not _skip(words[s : e + 1])
      ]
  
      # Concatenate into strings
      if as_strings:
          ngrams = [
              "{}".format(" ".join(words[s:e])) for (s, e) in ngrams
          ]
  
      return ngrams
  
imports: import copy
  import logging
  import regex
  import spacy
label_desc: Use image node_id 10 for calling the Tokens obj's underlying member method code with example usage: obj.ngrams(n, uncased, filter_fn, as_strings) and returns: ngrams, filter_fn, False