def compact(self, term_doc_matrix):
		'''
		Parameters
		-------
		term_doc_matrix : TermDocMatrix

		Returns
		-------
		New term doc matrix
		'''
		tdf = self.term_ranker(term_doc_matrix).get_ranks()
		tdf_sum = tdf.sum(axis=0)
		tdf_portions = tdf / tdf_sum
		threshold = np.max(self.term_count / tdf_sum)
		terms_to_remove = tdf_portions[~(tdf_portions > threshold).any(axis=1)].index
		return term_doc_matrix.remove_terms(terms_to_remove)
def compact ( self , term_doc_matrix ) : tdf = self . term_ranker ( term_doc_matrix ) . get_ranks ( ) tdf_sum = tdf . sum ( axis = 0 ) tdf_portions = tdf / tdf_sum threshold = np . max ( self . term_count / tdf_sum ) terms_to_remove = tdf_portions [ ~ ( tdf_portions > threshold ) . any ( axis = 1 ) ] . index return term_doc_matrix . remove_terms ( terms_to_remove )
Parameters
		-------
		term_doc_matrix : TermDocMatrix

		Returns
		-------
		New term doc matrix