(self, n=1, uncased=False, filter_fn=None, as_strings=True)
return ngrams
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
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
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 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
def ngrams ( self , n = 1 , uncased = False , filter_fn = None , as_strings = True ) : 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