def compact(self, term_doc_matrix, non_text=False):
		'''
		Parameters
		-------
		term_doc_matrix : TermDocMatrix
		non_text : bool

		Returnss
		-------
		New term doc matrix
		'''
		ranker = self.term_ranker(term_doc_matrix)
		if non_text:
			ranker = ranker.use_non_text_features()
		tdf = ranker.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, non_text=non_text)

		Parameters
		-------
		term_doc_matrix : TermDocMatrix
		non_text : bool

		Returnss
		-------
		New term doc matrix
		
scattertext/termcompaction/ClassPercentageCompactor.py