def update_tokens(self, tokens, size=None, minimum_occurrences=1, freqs=None):
        if freqs is None:
            freqs = self._get_frequency_count(tokens)
            
        if size is None or size == 0:
            # size None or 0 means no size limit
            size = len(freqs)
        
        if self.num_tokens >= size:
            return
        else:
            size_diff = size - self.num_tokens
        
        # a new version of freqs with only tokens not present in the dictionary
        # and above minimum frequency 
        candidate_tokens = dict((token, freqs[token])
                                for token in freqs 
                                if token not in self and freqs[token] >= minimum_occurrences)
        
        # order the types from the most frequent to the least
        new_tokens = sorted(candidate_tokens, key=lambda x: candidate_tokens[x], reverse=True)
        
        next_value = len(self)
        for token in new_tokens:
            self[token] = next_value
            next_value += 1
            size_diff -= 1
            if size_diff == 0:
                break
        
        self.check()
Tests that an exception raised in response to the given event is
dataset/ETHPy150Open erickrf/nlpnet/nlpnet/word_dictionary.py/WordDictionary.update_tokens--crossover with--dataset/ETHPy150Open amrdraz/kodr/app/brython/www/src/Lib/test/test_sys_settrace.py/RaisingTraceFuncTestCase.run_test_for_event