def filter_extremes(self, no_below=5, no_above=0.5, keep_n=100000):
        no_above_abs = int(no_above * self.num_docs) # convert fractional threshold to absolute threshold
        ok = [item for item in iteritems(self.dfs_debug)
                   if no_below <= item[1] <= no_above_abs]
        ok = frozenset(word for word, freq in sorted(ok, key=lambda item: -item[1])[:keep_n])

        self.dfs_debug = dict((word, freq)
                              for word, freq in iteritems(self.dfs_debug)
                              if word in ok)
        self.token2id = dict((token, tokenid)
                             for token, tokenid in iteritems(self.token2id)
                             if token in self.dfs_debug)
        self.id2token = dict((tokenid, set(token for token in tokens
                                                 if token in self.dfs_debug))
                             for tokenid, tokens in iteritems(self.id2token))
        self.dfs = dict((tokenid, freq)
                        for tokenid, freq in iteritems(self.dfs)
                        if self.id2token.get(tokenid, set()))

        # for word->document frequency
        logger.info("kept statistics for which were in no less than %i and no more than %i (=%.1f%%) documents" %
            (no_below, no_above_abs, 100.0 * no_above))
Create a queryset with a host given as a dict
dataset/ETHPy150Open largelymfs/topical_word_embeddings/TWE-1/gensim/corpora/hashdictionary.py/HashDictionary.filter_extremes--crossover with--dataset/ETHPy150Open Yipit/pyeqs/tests/unit/test_connection.py/test_create_queryset_with_host_dict