class_docstr: This implements wrapper for gensim lsa and tfidf analysis of text collection
code: def train(
      cls,
      texts,
      text_process,
      model="lsa",
      topic_n=100,
      top_N=100,
      save_dir="data/",
  ):
      import logging
  
      logging.basicConfig(
          format="%(asctime)s : %(levelname)s : %(message)s",
          level=logging.INFO,
      )
      corpus = [text_process(t) for t in texts]
      dictionary = corpora.Dictionary(corpus)
      print(dictionary)
      dictionary.save(save_dir + "dictionary")
      bow = [dictionary.doc2bow(t) for t in corpus]
      corpora.MmCorpus.serialize(save_dir + "bow", bow)
      bow_corpus = corpora.MmCorpus(save_dir + "bow")
      tfidf = models.TfidfModel(bow_corpus, id2word=dictionary)
      corpora.MmCorpus.serialize(save_dir + "tfidf", tfidf[bow_corpus])
      tfidf.save(save_dir + "tfidf.model")
      tfidf_corpus = corpora.MmCorpus(save_dir + "tfidf")
      tfidf_index = similarities.Similarity(
          save_dir + "tfidf_index/shard",
          tfidf_corpus,
          num_features=tfidf_corpus.num_terms,
      )
      tfidf_index.num_best = top_N
      tfidf_index.save(save_dir + "tfidf_index/tfidf.index")
      if model == "lsa":
          lsa = models.LsiModel(
              tfidf_corpus, id2word=dictionary, num_topics=topic_n
          )
          lsa.save(save_dir + "lsa.model")
          lsa_index = similarities.Similarity(
              save_dir + "lsa_index/shard",
              lsa[tfidf_corpus],
              num_features=topic_n,
          )
          lsa_index.num_best = top_N
          lsa_index.save(save_dir + "lsa_index/lsa.index")
          return cls(
              text_process,
              model,
              dictionary,
              tfidf,
              tfidf_index,
              lsa,
              lsa_index,
          )
      return cls(
          text_process,
          model,
          dictionary,
          tfidf,
          tfidf_index,
          None,
          None,
      )
  
file_path: sematch/sematch/semantic/analysis.py
imports: from gensim import corpora, models, similarities, matutils
label_desc: Use image node_id 6 for calling the TextAnalysis obj's underlying member method code with example usage: obj.train(cls, texts, text_process, model, topic_n, top_N, save_dir) and returns: cls, cls