class_docstr: This analyzer class analyzes text data and calculates the TF-IDF, TF for the input corpus,
  and percentage of pre-defined patterns
docstr: Map stats information into a json object
  
  Args:
      global_doc_frequency: a dictionary maps term to the count of documents globally that contain the term.
              Default is None, the tfidf will be calculated with the accumulated document frequency.
      total_doc_count: total number of documents corresponding to the global_doc_frequency
  
  Returns:
      A json that represents frequency count and total count
docstr_tok: ["Map","stats","information","into","a","json","object","Args",":","global_doc_frequency",":","a","dictionary","maps","term","to","the","count","of","documents","globally","that","contain","the","term",".","Default","is","None",",","the","tfidf","will","be","calculated","with","the","accumulated","document","frequency",".","total_doc_count",":","total","number","of","documents","corresponding","to","the","global_doc_frequency","Returns",":","A","json","that","represents","frequency","count","and","total","count"]
code: def get_statistics(
      self,
      global_doc_frequency: Optional[Dict[str, int]] = None,
      total_doc_count: Optional[int] = None,
  ) -> TextStats:
      """
      Map stats information into a json object
  
      Args:
          global_doc_frequency: a dictionary maps term to the count of documents globally that contain the term.
                  Default is None, the tfidf will be calculated with the accumulated document frequency.
          total_doc_count: total number of documents corresponding to the global_doc_frequency
  
      Returns:
          A json that represents frequency count and total count
      """
      tfidf = dict()
      if global_doc_frequency is None:
          for word in self._term_frequency.keys():
              tfidf[word] = (
                  self._term_frequency[word]
                  * math.log(
                      self._total_count / self._document_frequency[word]
                  )
                  / self._total_count
              )
      else:
          if total_doc_count is None:
              raise UndefinedRequiredParams("total_doc_count")
          for word in global_doc_frequency.keys():
              if word in self._term_frequency:
                  tfidf[word] = (
                      self._term_frequency[word]
                      * math.log(
                          total_doc_count / global_doc_frequency[word]
                      )
                      / self._total_count
                  )
              else:
                  tfidf[word] = 0
          for word in global_doc_frequency.keys():
              document_frequency = dict()
              document_frequency[word] = (
                  self._document_frequency[word]
                  if word in self._document_frequency
                  else 0
              )
  
      pattern_stats = dict()
      for pattern_name in self._pattern_occurrence_counter.keys():
          pattern_stats[pattern_name] = (
              self._pattern_occurrence_counter[pattern_name],
              self._pattern_document_counter[pattern_name],
          )
      stats = TextStats(
          total_count=self._total_count,
          pattern_stats=pattern_stats,
          word_count=dict(self._word_counter),
          char_count=dict(self._character_counter),
          term_frequency=dict(self._absolute_term_frequency),
          document_frequency=dict(self._document_frequency),
          tfidf=tfidf,
      )
      return stats
  
file_path: contextual-ai/xai/data/explorer/text/text_analyzer.py
imports: import math
  from collections import Counter
  from collections import defaultdict
  import re
  from nltk.corpus import stopwords
  from nltk.tokenize import word_tokenize
  from typing import Callable, Optional, Dict, List, Set
  from xai.data.constants import TermFrequencyType
  from xai.data.exceptions import InvalidTypeError, UndefinedRequiredParams
  from xai.data.explorer.abstract_analyzer import AbstractDataAnalyzer
  from xai.data.explorer.text.text_stats import TextStats
label_desc: Use image node_id 3 for calling the TextDataAnalyzer obj's underlying member method code with example usage: obj.get_statistics(global_doc_frequency, total_doc_count) and returns: stats