def __init__(
            self,
            corpus: Optional[TermDocMatrixWithoutCategories] = None,
            term_doc_mat: Optional[np.matrix] = None,
            non_text=False,
            use_categories_as_documents=False,
            tqdm=None,
            regressor=None,
            term_ranker: Optional[TermRanker] = None,
            vocabulary: Optional[List[str]] = None,
            add_smoothing_part: bool = False
    ):
        """
        corpus, Optional ]TermDocMatrix type-object; if not present, pass an argument to the `term_doc_mat` parameter
        term_doc_mat, Optional[np.matrix]; use this term doc matrix
        non_text bool, default False; use metadata features
        use_categories_as_document, bool, default False; use categories in lieu of documents
        add_smoothing_part: add a part containing one of every terms

        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)
        
        Adapted from Burch: y is percentage of tokens which are a terms in a part   
        '''
        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.")
        self.absent_vocab = []
        X = self.__get_X(corpus, non_text, term_doc_mat, term_ranker    , use_categories_as_documents)
        if corpus:
            if vocabulary is not None:
                self.absent_vocab = [v for v in vocabulary if v not in set(corpus.get_terms(use_metadata=non_text))]
            if self.absent_vocab:
                X = hstack([X, np.zeros((X.shape[0], len(self.absent_vocab)))])

        if add_smoothing_part:
            X = vstack([X, np.ones((1, X.shape[1]))])

        part_sizes = X.sum(axis=1)
        self.l = X.sum().sum()
        self.n = X.shape[0]
        self.f = X.sum(axis=0)
        self.term_part_counts = X  # v in Griess
        self.p_term_part = X.multiply(csc_matrix(1. / X.sum(axis=1)))
        self.prob_part = part_sizes / self.l  # s in gries
        self.tqdm = tqdm
        self.regressor = Lowess() if regressor is None else regressor

        corpus, Optional ]TermDocMatrix type-object; if not present, pass an argument to the `term_doc_mat` parameter
        term_doc_mat, Optional[np.matrix]; use this term doc matrix
        non_text bool, default False; use metadata features
        use_categories_as_document, bool, default False; use categories in lieu of documents
        add_smoothing_part: add a part containing one of every terms

        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

        
scattertext/dispersion/dispersion.py