(self, min_frequency)
trim word freq less than min_frequency
trim word freq less than min_frequency
trim word freq less than min_frequency
def trim(self, min_frequency):
    ''' trim word freq less than min_frequency'''
    # sort by frequency
    self._freq = sorted(self._freq.items(), key=lambda x: x[1], reverse=True)

    if self.use_default_dict:
      self._mapping = copy.deepcopy(self._default_dict)
      idx = len(self._default_dict)
    else:
      self._mapping = {}
      idx = 0

    for word, count in self._freq:
      if count < min_frequency:
        break
      if word in self._mapping:
        continue
      self._mapping[word] = idx
      idx += 1
    self._freq = dict(self._freq[:idx - 1])
def trim ( self , min_frequency ) : # sort by frequency self . _freq = sorted ( self . _freq . items ( ) , key = lambda x : x [ 1 ] , reverse = True ) if self . use_default_dict : self . _mapping = copy . deepcopy ( self . _default_dict ) idx = len ( self . _default_dict ) else : self . _mapping = { } idx = 0 for word , count in self . _freq : if count < min_frequency : break if word in self . _mapping : continue self . _mapping [ word ] = idx idx += 1 self . _freq = dict ( self . _freq [ : idx - 1 ] )