(self, filePath, sep='\t')
Truncate vocabulary to keep most frequent words
        
        Args:
            filePath: vocabulary file path, every line in the file represents 
                a word with a tab seperating word and it's frequency
            
        Returns:
            None
Truncate vocabulary to keep most frequent words
        
        Args:
            filePath: vocabulary file path, every line in the file represents 
                a word with a tab seperating word and it's frequency
            
        Returns:
            None
Truncate vocabulary to keep most frequent words Args : filePath : vocabulary file path every line in the file represents a word with a tab seperating word and it s frequency Returns : None
def load_vocab_from_file(self, filePath, sep='\t'):
        """
        Truncate vocabulary to keep most frequent words
        
        Args:
            filePath: vocabulary file path, every line in the file represents 
                a word with a tab seperating word and it's frequency
            
        Returns:
            None 
        """
        with open(filePath, 'rb') as fd:
            for line in fd:
                line_uni = line.strip().decode('utf-8')
                word, freq = line_uni.split(sep)
                index = len(self.word_to_index)
                if word not in self.word_to_index:
                    self.word_to_index[word] = index
                    self.index_to_word[index] = word
                self.word_freq[word] = int(freq)
            print 'load from <'+filePath+'>, there are {} words in dictionary'.format(len(self.word_freq))
def load_vocab_from_file ( self , filePath , sep = '\t' ) : with open ( filePath , 'rb' ) as fd : for line in fd : line_uni = line . strip ( ) . decode ( 'utf-8' ) word , freq = line_uni . split ( sep ) index = len ( self . word_to_index ) if word not in self . word_to_index : self . word_to_index [ word ] = index self . index_to_word [ index ] = word self . word_freq [ word ] = int ( freq ) print 'load from <' + filePath + '>, there are {} words in dictionary' . format ( len ( self . word_freq ) )