
    c	                     @   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZmZmZ ddlmZ dd	lmZ dd
lmZmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl m!Z! ddl"m#Z# ddl$m%Z% ddl&m'Z'm(Z( ddl)m*Z* ddl+m,Z, ddl-m.Z.m/Z/  G d de.j0                  Z1dS )zm
This package contains algorithms for extracting document representations from their raw
bag-of-word counts.
   )CoherenceModel)HdpModel)LdaModel)LsiModel)
TfidfModel)OkapiBM25ModelLuceneBM25ModelAtireBM25Model)RpModel)LogEntropyModel)Word2VecFAST_VERSION)Doc2Vec)KeyedVectors)LdaMulticore)Phrases)	NormModel)AuthorTopicModel)LdaSeqModel)FastText)TranslationMatrixBackMappingTranslationMatrix)EnsembleLda)Nmf    )
interfacesutilsc                        e Zd ZdZddZd ZdS )VocabTransforma  
    Remap feature ids to new values.

    Given a mapping between old ids and new ids (some old ids may be missing = these
    features are to be discarded), this will wrap a corpus so that iterating over
    `VocabTransform[corpus]` returns the same vectors but with the new ids.

    Old features that have no counterpart in the new ids are discarded. This
    can be used to filter vocabulary of a corpus "online":

    .. sourcecode:: pycon

        >>> old2new = {oldid: newid for newid, oldid in enumerate(ids_you_want_to_keep)}
        >>> vt = VocabTransform(old2new)
        >>> for vec_with_new_ids in vt[corpus_with_old_ids]:
        >>>     pass

    Nc                 "    || _         || _        d S N)old2newid2token)selfr"   r#   s      6lib/python3.11/site-packages/gensim/models/__init__.py__init__zVocabTransform.__init__3   s         c                      t          j        |          \  }}|r                     |          S t           fd|D                       S )zA
        Return representation with the ids transformed.
        c              3   N   K   | ]\  }}|j         v j         |         |fV   d S r!   )r"   ).0oldidweightr$   s      r%   	<genexpr>z-VocabTransform.__getitem__.<locals>.<genexpr>@   sB      ffvPUY]YePeft|E*F3ffffffr'   )r   	is_corpus_applysorted)r$   bowr.   s   `  r%   __getitem__zVocabTransform.__getitem__7   sU    
 --	3 	$;;s###ffffffffffr'   r!   )__name__
__module____qualname____doc__r&   r2    r'   r%   r   r      sF         &! ! ! !	g 	g 	g 	g 	gr'   r   N)2r6   coherencemodelr   hdpmodelr   ldamodelr   lsimodelr   
tfidfmodelr   	bm25modelr   r	   r
   rpmodelr   logentropy_modelr   word2vecr   r   doc2vecr   keyedvectorsr   ldamulticorer   phrasesr   	normmodelr   atmodelr   ldaseqmodelr   fasttextr   translation_matrixr   r   ensembleldar   nmfr   gensimr   r   TransformationABCr   r7   r'   r%   <module>rN      s    + * * * * *                   " " " " " " F F F F F F F F F F       - - - - - - , , , , , , , ,       & & & & & & & & & & & &                   % % % % % % $ $ $ $ $ $       O O O O O O O O $ $ $ $ $ $       $ $ $ $ $ $ $ $!g !g !g !g !gZ1 !g !g !g !g !gr'   