code: def analyze_texts(data_rdd):
      def index(w_c_i):
          ((w, c), i) = w_c_i
          return (w, (i + 1, c))
  
      return (
          data_rdd.flatMap(
              lambda text_label: text_to_words(text_label[0])
          )
          .map(lambda word: (word, 1))
          .reduceByKey(lambda a, b: a + b)
          .sortBy(lambda w_c: -w_c[1])
          .zipWithIndex()
          .map(lambda w_c_i: index(w_c_i))
          .collect()
      )
  
file_path: BigDL/python/dllib/src/bigdl/dllib/models/textclassifier/textclassifier.py
imports: import itertools
  import re
  from optparse import OptionParser
  from bigdl.dllib.feature.dataset import news20
  from bigdl.dllib.nn.layer import *
  from bigdl.dllib.nn.criterion import *
  from bigdl.dllib.optim.optimizer import *
  from bigdl.dllib.utils.common import *
  from bigdl.dllib.nncontext import *
  from bigdl.dllib.utils.utils import detect_conda_env_name
  import os
  import datetime
  from bigdl.dllib.utils.log4Error import *
label_desc: Use image node_id 2 for calling a global function with example usage: analyze_texts(data_rdd) and returns: data_rdd, w,  unknown,  c