docstr: From https://www.researchgate.net/publication/332120488_Analyzing_dispersion
  Stefan Th. Gries. Analyzing dispersion. April 2019. Practical handbook of corpus linguistics. Springer.
  
  Parts are considered documents, unless use_categories is True. Then categories are treated as parts.
  
  Term ranker is acttive is use_categories is True
docstr_tok: ["From","https",":","\/\/www.researchgate.net\/publication\/332120488_Analyzing_dispersion","Stefan","Th",".","Gries",".","Analyzing","dispersion",".","April","2019",".","Practical","handbook","of","corpus","linguistics",".","Springer",".","Parts","are","considered","documents",",","unless","use_categories","is","True",".","Then","categories","are","treated","as","parts",".","Term","ranker","is","acttive","is","use_categories","is","True"]
code: def __init__(
      self,
      corpus=None,
      term_doc_mat=None,
      non_text=False,
      use_categories=False,
      tqdm=None,
      regressor=None,
      term_ranker: Optional[TermRanker] = None,
  ):
      """
      From https://www.researchgate.net/publication/332120488_Analyzing_dispersion
      Stefan Th. Gries. Analyzing dispersion. April 2019. Practical handbook of corpus linguistics. Springer.
  
      Parts are considered documents, unless use_categories is True. Then categories are treated as parts.
  
      Term ranker is acttive is use_categories is True
      """
  
      """
          following Gries' notation, for the following example:
          b a m n i b e u p
          b a s a t b e w q n
          b c a g a b e s t a
          b a g h a b e a a t
          b a h a a b e a x a t
  
          (1) l = 50 (the length of the corpus in words)
          (2) n = 5 (the length of the corpus in parts)
          (3) s = (0.18, 0.2, 0.2, 0.2, 0.22) (the percentages of the n corpus part sizes)
          (4) f = 15 (the overall frequency of a in the corpus)
          (5) v = (1, 2, 3, 4, 5) (the frequencies of a in each corpus part 1-n)
          (6) p = (1/9, 2/10, 3/10, 4/10, 5 /11) (the percentages a makes up of each corpus part 1-n)
          """
      self.corpus = None
      self.use_metadata = non_text
      if corpus is None and term_doc_mat is None:
          raise Exception(
              "Required non-None argument for corpus or term_doc_mat."
          )
      X = self.__get_X(
          corpus, non_text, term_doc_mat, term_ranker, use_categories
      )
      part_sizes = X.sum(axis=1)
      self.l = X.sum().sum()
      self.n = X.shape[0]
      self.f = X.sum(axis=0)
      self.v = X
      self.p = X.multiply(csc_matrix(1.0 / X.sum(axis=1)))
      self.s = part_sizes / self.l
      self.tqdm = tqdm
      self.regressor = Lowess() if regressor is None else regressor
  
imports: from typing import Optional, Callable, List
  import numpy
  import pandas
  from scattertext.termranking import AbsoluteFrequencyRanker
  from scipy.sparse import csc_matrix, csr_matrix
  from sklearn.preprocessing import StandardScaler
  from scattertext.smoothing.lowess import Lowess
  from scattertext.termranking.TermRanker import TermRanker
  from scattertext.TermDocMatrix import TermDocMatrix
label_desc: Use image node_id 1 to create a new Dispersion object from inherited base classes: object with example: obj = Dispersion(corpus, term_doc_mat, non_text, use_categories, tqdm, regressor, term_ranker)