code: def test_compact_by_rank(self):
      term_doc_mat = get_hamlet_term_doc_matrix()
      compact_tdm4 = AssociationCompactorByRank(rank=4).compact(
          term_doc_mat
      )
      compact_tdm8 = AssociationCompactorByRank(rank=8).compact(
          term_doc_mat
      )
      self.assertLess(
          compact_tdm4.get_num_terms(), compact_tdm8.get_num_terms()
      )
      self.assertLess(
          compact_tdm8.get_num_terms(), term_doc_mat.get_num_terms()
      )
  
file_path: scattertext/scattertext/test/test_associationCompator.py
imports: from unittest import TestCase
  from scattertext.termcompaction.AssociationCompactor import AssociationCompactor, AssociationCompactorByRank, TermCategoryRanker
  from scattertext.test.test_TermDocMat import get_hamlet_term_doc_matrix
label_desc: Use image node_id 3 for calling the TestAssociationCompactor obj's underlying member method code with example usage: obj.test_compact_by_rank() without return types