docstr: Parameters
  ----------
  term_doc_matrix : TermDocMatrix
          Term document matrix object to compact
  
  Returns
  -------
  New term doc matrix
docstr_tok: ["Parameters","--","--","--","--","--","term_doc_matrix",":","TermDocMatrix","Term","document","matrix","object","to","compact","Returns","--","--","--","-","New","term","doc","matrix"]
code: def compact(self, term_doc_matrix, non_text=False):
      """
      Parameters
      ----------
      term_doc_matrix : TermDocMatrix
              Term document matrix object to compact
  
      Returns
      -------
      New term doc matrix
      """
      domain_mat = CombineDocsIntoDomains(
          term_doc_matrix
      ).get_new_term_doc_mat(self.doc_domains, non_text)
      domain_count = (domain_mat > 0).sum(axis=0)
      valid_term_mask = (self.max_domain_count >= domain_count) & (
          domain_count >= self.min_domain_count
      )
      indices_to_compact = np.arange(
          self._get_num_terms(term_doc_matrix, non_text)
      )[~valid_term_mask.A1]
      return term_doc_matrix.remove_terms_by_indices(
          indices_to_compact, non_text=non_text
      )
  
file_path: scattertext/scattertext/termcompaction/DomainCompactor.py
imports: import numpy
  from scattertext.domain.CombineDocsIntoDomains import CombineDocsIntoDomains
label_desc: Use image node_id 2 for calling the DomainCompactor obj's underlying member method code with example usage: obj.compact(term_doc_matrix, non_text) and returns: term_doc_matrix