(self, tokenized_docs: Iterable[Iterable[str]])
return doc_term_matrix
Count terms and, if :attr:`Vectorizer.fixed_terms` is False, build up
        a vocabulary based on the terms found in ``tokenized_docs``. Transform
        ``tokenized_docs`` into a document-term matrix with absolute tf weights.
        Store global weights (IDFs) and, if :attr:`Vectorizer.doc_length_norm`
        is not None, the average doc length.

        Args:
            tokenized_docs

        Returns:
            Document-term matrix.
Count terms and, if :attr:`Vectorizer.fixed_terms` is False, build up
        a vocabulary based on the terms found in ``tokenized_docs``. Transform
        ``tokenized_docs`` into a document-term matrix with absolute tf weights.
        Store global weights (IDFs) and, if :attr:`Vectorizer.doc_length_norm`
        is not None, the average doc length.
Count terms and if : attr : Vectorizer . fixed_terms is False build up a vocabulary based on the terms found in tokenized_docs . Transform tokenized_docs into a document - term matrix with absolute tf weights . Store global weights ( IDFs ) and if : attr : Vectorizer . doc_length_norm is not None the average doc length .
def _fit(self, tokenized_docs: Iterable[Iterable[str]]) -> sp.csr_matrix:
        """
        Count terms and, if :attr:`Vectorizer.fixed_terms` is False, build up
        a vocabulary based on the terms found in ``tokenized_docs``. Transform
        ``tokenized_docs`` into a document-term matrix with absolute tf weights.
        Store global weights (IDFs) and, if :attr:`Vectorizer.doc_length_norm`
        is not None, the average doc length.

        Args:
            tokenized_docs

        Returns:
            Document-term matrix.
        """
        # count terms and, if not provided on init, build up a vocabulary
        doc_term_matrix, vocabulary_terms = self._count_terms(
            tokenized_docs, self._fixed_terms
        )

        if self._fixed_terms is False:
            # filter terms by doc freq or info content, as specified in init
            doc_term_matrix, vocabulary_terms = self._filter_terms(
                doc_term_matrix, vocabulary_terms
            )
            # sort features alphabetically (vocabulary_terms modified in-place)
            doc_term_matrix = self._sort_vocab_and_matrix(
                doc_term_matrix, vocabulary_terms, axis="columns"
            )
            # *now* vocabulary_terms are known and fixed
            self.vocabulary_terms = vocabulary_terms
            self._fixed_terms = True

        n_docs, n_terms = doc_term_matrix.shape

        if self.idf_type:
            # store the global weights as a diagonal sparse matrix of idfs
            idfs = get_inverse_doc_freqs(doc_term_matrix, type_=self.idf_type)
            self._idf_diag = sp.spdiags(
                idfs, diags=0, m=n_terms, n=n_terms, format="csr"
            )

        if self.tf_type == "bm25" and self.dl_type:
            # store the avg document length, used in bm25 weighting to normalize
            # term weights by the length of the containing documents
            self._avg_doc_length = get_doc_lengths(
                doc_term_matrix, type_=self.dl_type
            ).mean()

        return doc_term_matrix
def _fit ( self , tokenized_docs : Iterable [ Iterable [ str ] ] ) -> sp . csr_matrix : # count terms and, if not provided on init, build up a vocabulary doc_term_matrix , vocabulary_terms = self . _count_terms ( tokenized_docs , self . _fixed_terms ) if self . _fixed_terms is False : # filter terms by doc freq or info content, as specified in init doc_term_matrix , vocabulary_terms = self . _filter_terms ( doc_term_matrix , vocabulary_terms ) # sort features alphabetically (vocabulary_terms modified in-place) doc_term_matrix = self . _sort_vocab_and_matrix ( doc_term_matrix , vocabulary_terms , axis = "columns" ) # *now* vocabulary_terms are known and fixed self . vocabulary_terms = vocabulary_terms self . _fixed_terms = True n_docs , n_terms = doc_term_matrix . shape if self . idf_type : # store the global weights as a diagonal sparse matrix of idfs idfs = get_inverse_doc_freqs ( doc_term_matrix , type_ = self . idf_type ) self . _idf_diag = sp . spdiags ( idfs , diags = 0 , m = n_terms , n = n_terms , format = "csr" ) if self . tf_type == "bm25" and self . dl_type : # store the avg document length, used in bm25 weighting to normalize # term weights by the length of the containing documents self . _avg_doc_length = get_doc_lengths ( doc_term_matrix , type_ = self . dl_type ) . mean ( ) return doc_term_matrix