parameters: (self, min_frequency, max_frequency=-1)
docstring: Trims vocabulary for minimum frequency.
  
      Remaps ids from 1..n in sort frequency order.
      where n - number of elements left.
  
      Args:
        min_frequency: minimum frequency to keep.
        max_frequency: optional, maximum frequency to keep.
          Useful to remove very frequent categories (like stop words).
docstring_summary: Trims vocabulary for minimum frequency.
docstring_tokens: Trims vocabulary for minimum frequency .
function: def trim(self, min_frequency, max_frequency=-1):
      """Trims vocabulary for minimum frequency.
  
      Remaps ids from 1..n in sort frequency order.
      where n - number of elements left.
  
      Args:
        min_frequency: minimum frequency to keep.
        max_frequency: optional, maximum frequency to keep.
          Useful to remove very frequent categories (like stop words).
      """
      # Sort by alphabet then reversed frequency.
      self._freq = sorted(
          sorted(
              six.iteritems(self._freq),
              key=lambda x: (isinstance(x[0], str), x[0])),
          key=lambda x: x[1],
          reverse=True)
      self._mapping = {self._unknown_token: 0}
      if self._support_reverse:
        self._reverse_mapping = [self._unknown_token]
      idx = 1
      for category, count in self._freq:
        if max_frequency > 0 and count >= max_frequency:
          continue
        if count <= min_frequency:
          break
        self._mapping[category] = idx
        idx += 1
        if self._support_reverse:
          self._reverse_mapping.append(category)
      self._freq = dict(self._freq[:idx - 1])
function_tokens: def trim ( self , min_frequency , max_frequency = - 1 ) : # Sort by alphabet then reversed frequency. self . _freq = sorted ( sorted ( six . iteritems ( self . _freq ) , key = lambda x : ( isinstance ( x [ 0 ] , str ) , x [ 0 ] ) ) , key = lambda x : x [ 1 ] , reverse = True ) self . _mapping = { self . _unknown_token : 0 } if self . _support_reverse : self . _reverse_mapping = [ self . _unknown_token ] idx = 1 for category , count in self . _freq : if max_frequency > 0 and count >= max_frequency : continue if count <= min_frequency : break self . _mapping [ category ] = idx idx += 1 if self . _support_reverse : self . _reverse_mapping . append ( category ) self . _freq = dict ( self . _freq [ : idx - 1 ] )