code: def build_hamlet_jz_term_doc_mat():
      # type: () -> TermDocMatrix
      categories, documents = get_docs_categories()
      clean_function = lambda text: "" if text.startswith("[") else text
      term_doc_mat = TermDocMatrixFactory(
          category_text_iter=zip(categories, documents),
          clean_function=clean_function,
          nlp=whitespace_nlp,
      ).build()
      return term_doc_mat
  
imports: import re
  from unittest import TestCase
  import pandas
  from sklearn.feature_extraction.text import TfidfTransformer
  from sklearn.linear_model import PassiveAggressiveClassifier
  from scattertext import CorpusFromParsedDocuments
  from scattertext import FeatsFromSpacyDoc, FeatsFromSpacyDocAndEmpath
  from scattertext import TermDocMatrixFactory
  from scattertext.TermDocMatrixFactory import FeatsFromDoc
  from scattertext.WhitespaceNLP import whitespace_nlp, Doc, Tok
label_desc: Use image node_id 1 for calling a global function with example usage: build_hamlet_jz_term_doc_mat() and returns: term_doc_mat