
    cd                        d Z ddlmZ ddlmZ ddlZddlmZ ddlZddl	m
Z
 ddlmZ ddlmZmZ  ej        e          Zd	Z G d
 de          Z G d de          Z G d de          Zd Zd Zd Zd Zd Z G d de          ZdS )z@
This module provides classes that deal with term similarities.
    )array)chainN)sqrt)sparse)
corpus2csc)SaveLoad	is_corpuszsparse documents must not contain any explicit zero entries and the similarity matrix S must satisfy x^T * S * x >= 0 for any nonzero bag-of-words vector x.c                        e Zd ZdZddZd ZdS )TermSimilarityIndexa  
    Base class = common interface for retrieving the most similar terms for a given term.

    See Also
    --------
    :class:`~gensim.similarities.termsim.SparseTermSimilarityMatrix`
        A sparse term similarity matrix built using a term similarity index.

    
   c                     t           )aK  Get most similar terms for a given term.

        Return the most similar terms for a given term along with their similarities.

        Parameters
        ----------
        term : str
            The term for which we are retrieving `topn` most similar terms.
        topn : int, optional
            The maximum number of most similar terms to `term` that will be retrieved.

        Returns
        -------
        iterable of (str, float)
            Most similar terms along with their similarities to `term`. Only terms distinct from
            `term` must be returned.

        )NotImplementedError)selftermtopns      ;lib/python3.11/site-packages/gensim/similarities/termsim.pymost_similarz TermSimilarityIndex.most_similar)   s
    & "!    c                     d                     d t          |                                           D                       }| j        j        d|dS )Nz, c              3       K   | ]	}d |z  V  
dS )z%s=%sN ).0pairs     r   	<genexpr>z.TermSimilarityIndex.__str__.<locals>.<genexpr>?   s&      JJtGdNJJJJJJr   <>)joinvarsitems	__class____name__)r   memberss     r   __str__zTermSimilarityIndex.__str__>   sN    ))JJtDzz7G7G7I7IJJJJJ>222GGG<<r   Nr   )r!   
__module____qualname____doc__r   r#   r   r   r   r   r      sA         " " " "*= = = = =r   r   c                   "    e Zd ZdZddZddZdS )	UniformTermSimilarityIndexa  
    Retrieves most similar terms for a given term under the hypothesis that the similarities between
    distinct terms are uniform.

    Parameters
    ----------
    dictionary : :class:`~gensim.corpora.dictionary.Dictionary`
        A dictionary that specifies the considered terms.
    term_similarity : float, optional
        The uniform similarity between distinct terms.

    See Also
    --------
    :class:`~gensim.similarities.termsim.SparseTermSimilarityMatrix`
        A sparse term similarity matrix built using a term similarity index.

    Notes
    -----
    This class is mainly intended for testing SparseTermSimilarityMatrix and other classes that
    depend on the TermSimilarityIndex.

          ?c                 `    t          |                                          | _        || _        d S N)sortedr   
dictionaryterm_similarity)r   r.   r/   s      r   __init__z#UniformTermSimilarityIndex.__init__Z   s+     !1!1!3!344.r   r   c              #      K   t          t          |          fd| j        D                       D ]\  }\  }}|| j        fV  d S )Nc              3   2   K   | ]\  }}|k    ||fV  d S r,   r   )r   t2_indext2t1s      r   r   z:UniformTermSimilarityIndex.most_similar.<locals>.<genexpr>_   sQ       4P 4P#/8RbBh4P24P 4P 4P 4P 4P 4Pr   )zipranger.   r/   )r   r5   r   __r3   r4   s    `    r   r   z'UniformTermSimilarityIndex.most_similar^   s      "%eDkk 4P 4P 4P 4P37?4P 4P 4P #Q #Q 	- 	-B2t+,,,,,	- 	-r   N)r*   r$   )r!   r%   r&   r'   r0   r   r   r   r   r)   r)   C   sF         ,/ / / /- - - - - -r   r)   c                   ,     e Zd ZdZd fd	Zd	dZ xZS )
WordEmbeddingSimilarityIndexaz	  
    Computes cosine similarities between word embeddings and retrieves most
    similar terms for a given term.

    Notes
    -----
    By fitting the word embeddings to a vocabulary that you will be using, you
    can eliminate all out-of-vocabulary (OOV) words that you would otherwise
    receive from the `most_similar` method. In subword models such as fastText,
    this procedure will also infer word-vectors for words from your vocabulary
    that previously had no word-vector.

    >>> from gensim.test.utils import common_texts, datapath
    >>> from gensim.corpora import Dictionary
    >>> from gensim.models import FastText
    >>> from gensim.models.word2vec import LineSentence
    >>> from gensim.similarities import WordEmbeddingSimilarityIndex
    >>>
    >>> model = FastText(common_texts, vector_size=20, min_count=1)  # train word-vectors on a corpus
    >>> different_corpus = LineSentence(datapath('lee_background.cor'))
    >>> dictionary = Dictionary(different_corpus)  # construct a vocabulary on a different corpus
    >>> words = [word for word, count in dictionary.most_common()]
    >>> word_vectors = model.wv.vectors_for_all(words)  # remove OOV word-vectors and infer word-vectors for new words
    >>> assert len(dictionary) == len(word_vectors)  # all words from our vocabulary received their word-vectors
    >>> termsim_index = WordEmbeddingSimilarityIndex(word_vectors)

    Parameters
    ----------
    keyedvectors : :class:`~gensim.models.keyedvectors.KeyedVectors`
        The word embeddings.
    threshold : float, optional
        Only embeddings more similar than `threshold` are considered when retrieving word embeddings
        closest to a given word embedding.
    exponent : float, optional
        Take the word embedding similarities larger than `threshold` to the power of `exponent`.
    kwargs : dict or None
        A dict with keyword arguments that will be passed to the
        :meth:`~gensim.models.keyedvectors.KeyedVectors.most_similar` method
        when retrieving the word embeddings closest to a given word embedding.

    See Also
    --------
    :class:`~gensim.similarities.levenshtein.LevenshteinSimilarityIndex`
        Retrieve most similar terms for a given term using the Levenshtein distance.
    :class:`~gensim.similarities.termsim.SparseTermSimilarityMatrix`
        Build a term similarity matrix and compute the Soft Cosine Measure.

                   @Nc                     || _         || _        || _        |pi | _        t	          t
          |                                            d S r,   )keyedvectors	thresholdexponentkwargssuperr:   r0   )r   r>   r?   r@   rA   r    s        r   r0   z%WordEmbeddingSimilarityIndex.__init__   sG    (" l*D11::<<<<<r   r   c              #      K   || j         vrt                              d|           d S  | j         j        d|g|d| j        }|D ]\  }}|| j        k    r||| j        z  fV  d S )Nzan out-of-dictionary term "%s")positiver   r   )r>   loggerdebugr   rA   r?   r@   )r   r5   r   r   r4   
similaritys         r   r   z)WordEmbeddingSimilarityIndex.most_similar   s      T&& 	:LL92>>>>>94,9bB4dbbVZVabbL". : :J. :z4=89999: :r   )r;   r<   Nr$   )r!   r%   r&   r'   r0   r   __classcell__)r    s   @r   r:   r:   d   s\        / /`= = = = = =: : : : : : : :r   r:   c                     | dk     rt           j        S | dk     rt           j        S | dk     rt           j        S t           j        S )a  Get the shortest unsingned integer data-type required for representing values up to a given
    maximum value.

    Returns the shortest unsingned integer data-type required for representing values up to a given
    maximum value.

    Parameters
    ----------
    max_value : int
        The maximum value we wish to represent.

    Returns
    -------
    data-type
        The shortest unsigned integer data-type required for representing values up to a given
        maximum value.
       i   l        )npuint8uint16uint32uint64)	max_values    r   _shortest_uint_dtyperQ      sJ    $ 4 x	U	 y	U	 y9r   c                    t          | t                    sJ J t                    }|dk    rt          d          t                              d|            |fd}Jt                                                    }	t                              dt          |	                     nmt          j	                  |dz
  k    sJ t          j	                                        |          }	t                              d	t          |	                     t                    }
t          j        dg|z  |

          rt          j        ||
          rt                      t          d          t          d          |t          j        u s|t          j        u rt          d          n0|t          j        u rt          d          nt          d|z            fd}fd}	 ddlm} n# t&          $ r d }Y nw xY wt)           ||	                    D ]\  }}                    |                               |                               d           dk    rK|         }|         }|z
  }|dk    r#fd|                     ||          D             ng }t          |          }nt          ||          }|D ]J\  }} ||||          rs ||||           # ||||          s ||||            ||||           Kt          j        |
          t          j        t          j        
          t          j        t          j        
          t3          j        ff||f          }t                              dd|                                z  |dz  z             |S )zBuild a sparse term similarity matrix using a term similarity index.

    Returns
    -------
    matrix : :class:`scipy.sparse.coo_matrix`
        The sparse term similarity matrix.

    Nr   zCDictionary provided to SparseTermSimilarityMatrix must not be emptyz5constructing a sparse term similarity matrix using %sc                 Z    t          | t                    r| ^} }j        |          }| | fS r,   )
isinstancetupleidfs)
term_index_term_idftfidfs      r   tfidf_sort_keyz&_create_source.<locals>.tfidf_sort_key   s7    j%(( 	('NJ:j)	:&&r   z-iterating over %i columns in dictionary order   )keyz)iterating over %i columns in tf-idf orderdtypeQfdz@Dtype %s is unsupported, use numpy.float16, float32, or float64.c                     r|          t          |          z   dk    rdS |          k    sJ |          k    rdS r| |fv rdS dS )N      ?TF)abs)	t1_indexr3   rG   assigned_cellscolumn_nonzero
column_sumdominantnonzero_limit	symmetrics	      r   	cell_fullz!_create_source.<locals>.cell_full   s|     	
8,s:>#E 	4h'=8888(#}4 	4 	(H-? 	4ur   c                                         |            	                     |                                |           | xx         dz  cc<   
r                    | |f           r| xx         t          |          z  cc<   d S d S )Nr\   )appendaddre   )rf   r3   rG   rg   column_bufferrh   ri   data_bufferrj   
row_bufferrl   s      r   populate_buffersz(_create_source.<locals>.populate_buffers   s    X&&&(###:&&&x   A%    	5(3444 	4x   C
OO3     	4 	4r   )tqdmc                     | S r,   r   )iterables    r   progress_barz$_create_source.<locals>.progress_bar  s    Or   rd   c                 F    g | ]\  }}|j         v j         |         |fS r   )token2id)r   r   rG   r.   s      r   
<listcomp>z"_create_source.<locals>.<listcomp>  sH     
 
 
 jz**
 &
3
 
 
r   )r   )shapezAconstructed a sparse term similarity matrix with %0.06f%% densityg      Y@   )rT   r   len
ValueErrorrE   infor-   keysmaxrV   rQ   rK   r   zerossetfloat16float32float64ru   ImportError	enumeratero   r   
frombufferrO   r   
coo_matrixgetnnz)indexr.   rZ   rl   rj   rk   r_   matrix_orderr[   columnsnonzero_counter_dtyperm   rt   rx   column_numberrf   r5   num_nonzeronum_rowsr   rowsr3   rG   matrixrg   rq   rh   ri   rr   rs   s    `````                  @@@@@@r   _create_sourcer      s    e011111!!!z??Lq `^___
KKGOOO %$' ' ' ' '  O**++CS\\RRRR5:,"22222**????WNNN0??XqcL08MNNNN 9Xl%888
 sJ#JJM
 eerz1 eCjj	"*	 eCjj[^ccddd         4 4 4 4 4 4 4 4 4 4 4 4-------   	 	 	 	 	 $-\\'-B-B#C#C A Ax]+++-(((3A 	!$X. ;.
 \	" 
 
 
 
$)$6$6r$6$I$I
 
 
 
  "	 	  	<,''DD,N;;;D$( 	A 	A Hjy8Z88  A  8Z@@@@Yx:>> A  8Z@@@  8Z@@@	A -5999Kz;;;JM-ryAAAMj--HIR^`lQmnnnF
KKK,/1  
 Ms   
H H! H!c                 (   |s| S | j                             |                              |           d         }|dk    sJ t                      |dk    r#|dk    r|| j                             |           z  }t          |          }| }|dk    r||z  }|S )ai  Normalize a dense vector after a change of basis.

    Parameters
    ----------
    vector : 1xN ndarray
        A dense vector.
    matrix : NxN ndarray
        A change-of-basis matrix.
    normalization : {True, False, 'maintain'}
        Whether the vector will be L2-normalized (True; corresponds to the soft
        cosine measure), maintain its L2-norm during the change of basis
        ('maintain'; corresponds to query expansion with partial membership),
        or kept as-is (False; corresponds to query expansion).

    Returns
    -------
    vector : ndarray
        The normalized dense vector.

    r   r   r;   maintain)Tdot#NON_NEGATIVE_NORM_ASSERTION_MESSAGEr   )vectorr   normalizationvector_normnormalized_vectors        r   _normalize_dense_vectorr   :  s    *  (,,v&&**62248K#BBBBBB
" ,{S'8 ,vx||F+++{##KS )[(r   c                    |s| S t          j        | j                            |          | j                                      d          j        }|                                dk    sJ t                      |dk    r;|t          j        | j        | j                                      d          j        z  }t          j        |          }t          j        | d|z            }t          j        |          }|S )at  Normalize a dense corpus after a change of basis.

    Parameters
    ----------
    corpus : MxN ndarray
        A dense corpus.
    matrix : NxN ndarray
        A change-of-basis matrix.
    normalization : {True, False, 'maintain'}
        Whether the vector will be L2-normalized (True; corresponds to the soft
        cosine measure), maintain its L2-norm during the change of basis
        ('maintain'; corresponds to query expansion with partial membership),
        or kept as-is (False; corresponds to query expansion).

    Returns
    -------
    normalized_corpus : ndarray
        The normalized dense corpus.

    r\   axisr;   r   rd   )	rK   multiplyr   r   summinr   r   
nan_to_numcorpusr   r   corpus_normnormalized_corpuss        r   _normalize_dense_corpusr   _  s    *   +fhll622FH==AAqAIIKK??#HH%HHHH
" Er{68VX66:::BBDD'+&&KFC+,=>>&788r   c                    |s| S | j                             |                              | j                                       d          j         }|                                dk    sJ t
                      |dk    r;|| j                             | j                                       d          j         z  }t          j        |          }|                     t          j	        d|z                      }d||t          j
        k    <   |S )a  Normalize a sparse corpus after a change of basis.

    Parameters
    ----------
    corpus : MxN :class:`scipy.sparse.csc_matrix`
        A sparse corpus.
    matrix : NxN :class:`scipy.sparse.csc_matrix`
        A change-of-basis matrix.
    normalization : {True, False, 'maintain'}
        Whether the vector will be L2-normalized (True; corresponds to the soft
        cosine measure), maintain its L2-norm during the change of basis
        ('maintain'; corresponds to query expansion with partial membership),
        or kept as-is (False; corresponds to query expansion).

    Returns
    -------
    normalized_corpus : :class:`scipy.sparse.csc_matrix`
        The normalized sparse corpus.

    r\   r   r;   r   rd   r   )r   r   r   r   r   r   rK   r   r   
csr_matrixinfr   s        r   _normalize_sparse_corpusr     s    *   (,,v&&//99==1=EEGK??#HH%HHHH
" Avx((2266A6>>@@'+&&K(9#:K(L(LMM56'2612r   c                   8    e Zd ZdZdddddej        fdZd	dZdS )
SparseTermSimilarityMatrixa[  
    Builds a sparse term similarity matrix using a term similarity index.

    Examples
    --------
    >>> from gensim.test.utils import common_texts as corpus, datapath
    >>> from gensim.corpora import Dictionary
    >>> from gensim.models import Word2Vec
    >>> from gensim.similarities import SoftCosineSimilarity, SparseTermSimilarityMatrix, WordEmbeddingSimilarityIndex
    >>> from gensim.similarities.index import AnnoyIndexer
    >>>
    >>> model_corpus_file = datapath('lee_background.cor')
    >>> model = Word2Vec(corpus_file=model_corpus_file, vector_size=20, min_count=1)  # train word-vectors
    >>>
    >>> dictionary = Dictionary(corpus)
    >>> tfidf = TfidfModel(dictionary=dictionary)
    >>> words = [word for word, count in dictionary.most_common()]
    >>> word_vectors = model.wv.vectors_for_all(words, allow_inference=False)  # produce vectors for words in corpus
    >>>
    >>> indexer = AnnoyIndexer(word_vectors, num_trees=2)  # use Annoy for faster word similarity lookups
    >>> termsim_index = WordEmbeddingSimilarityIndex(word_vectors, kwargs={'indexer': indexer})
    >>> similarity_matrix = SparseTermSimilarityMatrix(termsim_index, dictionary, tfidf)  # compute word similarities
    >>>
    >>> tfidf_corpus = tfidf[[dictionary.doc2bow(document) for document in common_texts]]
    >>> docsim_index = SoftCosineSimilarity(tfidf_corpus, similarity_matrix, num_best=10)  # index tfidf_corpus
    >>>
    >>> query = 'graph trees computer'.split()  # make a query
    >>> sims = docsim_index[dictionary.doc2bow(query)]  # find the ten closest documents from tfidf_corpus

    Check out `the Gallery <https://radimrehurek.com/gensim/auto_examples/tutorials/run_scm.html>`_
    for more examples.

    Parameters
    ----------
    source : :class:`~gensim.similarities.termsim.TermSimilarityIndex` or :class:`scipy.sparse.spmatrix`
        The source of the term similarity. Either a term similarity index that will be used for
        building the term similarity matrix, or an existing sparse term similarity matrix that will
        be encapsulated and stored in the matrix attribute. When a matrix is specified as the
        source, any other parameters will be ignored.
    dictionary : :class:`~gensim.corpora.dictionary.Dictionary` or None, optional
        A dictionary that specifies a mapping between terms and the indices of rows and columns
        of the resulting term similarity matrix. The dictionary may only be None when source is
        a :class:`scipy.sparse.spmatrix`.
    tfidf : :class:`gensim.models.tfidfmodel.TfidfModel` or None, optional
        A model that specifies the relative importance of the terms in the dictionary. The columns
        of the term similarity matrix will be build in a decreasing order of importance of
        terms, or in the order of term identifiers if None.
    symmetric : bool, optional
        Whether the symmetry of the term similarity matrix will be enforced. Symmetry is a necessary
        precondition for positive definiteness, which is necessary if you later wish to derive a
        unique change-of-basis matrix from the term similarity matrix using Cholesky factorization.
        Setting symmetric to False will significantly reduce memory usage during matrix construction.
    dominant: bool, optional
        Whether the strict column diagonal dominance of the term similarity matrix will be enforced.
        Strict diagonal dominance and symmetry are sufficient preconditions for positive
        definiteness, which is necessary if you later wish to derive a change-of-basis matrix from
        the term similarity matrix using Cholesky factorization.
    nonzero_limit : int or None, optional
        The maximum number of non-zero elements outside the diagonal in a single column of the
        sparse term similarity matrix. If None, then no limit will be imposed.
    dtype : numpy.dtype, optional
        The data type of the sparse term similarity matrix.

    Attributes
    ----------
    matrix : :class:`scipy.sparse.csc_matrix`
        The encapsulated sparse term similarity matrix.

    Raises
    ------
    ValueError
        If `dictionary` is empty.

    See Also
    --------
    :class:`~gensim.similarities.docsim.SoftCosineSimilarity`
        A document similarity index using the soft cosine similarity over the term similarity matrix.
    :class:`~gensim.similarities.termsim.LevenshteinSimilarityIndex`
        A term similarity index that computes Levenshtein similarities between terms.
    :class:`~gensim.similarities.termsim.WordEmbeddingSimilarityIndex`
        A term similarity index that computes cosine similarities between word embeddings.

    NTFd   c                     t          j        |          s*|}|||||||f}	t          |	 }t          j        |          sJ |                                | _        d S r,   )r   issparser   tocscr   )
r   sourcer.   rZ   rl   rj   rk   r_   r   argss
             r   r0   z#SparseTermSimilarityMatrix.__init__  sc     v&& 	+E:ui=RWXD#T*F?6*****llnnr   FFc           
         rs| j         j                            d          S |\  }}d}||vr"t          d                    |                    ||vr"t          d                    |                    t                    \  }t                    \  }|sM|sJt                    t                    t          j        t          t          t                                                  }	| j         j        }
t          j        fd|	D             |
          t          j        fd|	D             |
          | j         |	dddf         |	f                                         }t          ||          t          ||          j                            |                                        }|du r|du rt          j        |d	d
          }|d         S |r|s|r|sc||}}||}}d}nd}| j         j        }
t#          g| j         j        d         |
          j                            | j                   }t          j        t          |                                d                             }	~t                    t          j        fd|	D             |
          t#          | j         j        d         |
          |	ddf                                         | j         |	dddf         |	f                                         }t          ||          t)          ||                              |                                        }|du r|du rt          j        |d	d
          }|r|j        }|S | j         j        }
t#          |rng| j         j        d         |
          t#          |rng| j         j        d         |
          | j         }t+          ||          t+          ||          j                            |                                        }|du r$|du r t          j        |j        d	d
          |_        |S )uV  Get the inner product(s) between real vectors / corpora X and Y.

        Return the inner product(s) between real vectors / corpora vec1 and vec2 expressed in a
        non-orthogonal normalized basis, where the dot product between the basis vectors is given by
        the sparse term similarity matrix.

        Parameters
        ----------
        vec1 : list of (int, float) or iterable of list of (int, float)
            A query vector / corpus in the sparse bag-of-words format.
        vec2 : list of (int, float) or iterable of list of (int, float)
            A document vector / corpus in the sparse bag-of-words format.
        normalized : tuple of {True, False, 'maintain'}, optional
            First/second value specifies whether the query/document vectors in the inner product
            will be L2-normalized (True; corresponds to the soft cosine measure), maintain their
            L2-norm during change of basis ('maintain'; corresponds to query expansion with partial
            membership), or kept as-is (False; corresponds to query expansion; default).

        Returns
        -------
        `self.matrix.dtype`,  `scipy.sparse.csr_matrix`, or :class:`numpy.matrix`
            The inner product(s) between `X` and `Y`.

        References
        ----------
        The soft cosine measure was perhaps first described by [sidorovetal14]_.
        Further notes on the efficient implementation of the soft cosine measure are described by
        [novotny18]_.

        .. [sidorovetal14] Grigori Sidorov et al., "Soft Similarity and Soft Cosine Measure: Similarity
           of Features in Vector Space Model", 2014, http://www.cys.cic.ipn.mx/ojs/index.php/CyS/article/view/2043/1921.

        .. [novotny18] Vít Novotný, "Implementation Notes for the Soft Cosine Measure", 2018,
           http://dx.doi.org/10.1145/3269206.3269317.

        r;   )TFr   z${} is not a valid value of normalizec                 ,    g | ]}|v r|         nd S r   r   r   iXs     r   r{   z<SparseTermSimilarityMatrix.inner_product.<locals>.<listcomp>>  *    FFFA!q&/!A$$aFFFr   r^   c                 ,    g | ]}|v r|         nd S r   r   )r   r   Ys     r   r{   z<SparseTermSimilarityMatrix.inner_product.<locals>.<listcomp>?  r   r   NTg      rd   r   Fr   )	num_termsr_   r\   c                 ,    g | ]}|v r|         nd S r   r   r   s     r   r{   z<SparseTermSimilarityMatrix.inner_product.<locals>.<listcomp>Y  r   r   )r   r_   typer   formatr	   dictrK   r   r-   r   r   todenser   r   r   clipr   r|   nonzeror   r   data)r   r   r   
normalizednormalized_Xnormalized_Yvalid_normalized_valuesis_corpus_Xis_corpus_Yword_indicesr_   r   result
transposed
expanded_Xs    ``            r   inner_productz(SparseTermSimilarityMatrix.inner_product  s   J  	/ 	/;$))#...%/"l";66 	ZCJJ<XXYYY66 	ZCJJ<XXYYY"1Q"1Q <	; <	QAQA8F3uQ{{+;+;$<$<==LK%EFFFFFFFeTTTAFFFFFFFeTTTA[aaag!6!DEMMOOF'6<@@A'6<@@ASWWV__((++Ft# 4(< 4s33$< +	K +	 #; #!1+6[-9<l!

"
K%E#QC4;3DQ3GuUUUW[[\`\ghhJ8F:+=+=+?+?+B$C$CDDLQAFFFFFFFeTTTA1(9!(<EJJJ<YZYZYZ?[cceeA[aaag!6!DEMMOOF'6<@@A'6<@@AUU6]]&&q))Ft# 4(< 4s33 "MK%E411!@QRS@T\abbbA411!@QRS@T\abbbA[F(FLAAA(FLAAASWWV__((++Ft# >(< > gfk4==Mr   )r   )r!   r%   r&   r'   rK   r   r0   r   r   r   r   r   r     sb        R Rf +/ddUZRZ	% 	% 	% 	%o o o o o or   r   )r'   r   	itertoolsr   loggingmathr   numpyrK   scipyr   gensim.matutilsr   gensim.utilsr   r	   	getLoggerr!   rE   r   r   r)   r:   rQ   r   r   r   r   r   r   r   r   <module>r      s                                 & & & & & & , , , , , , , ,		8	$	$& $!= != != != !=( != != !=H- - - - -!4 - - -B?: ?: ?: ?: ?:#6 ?: ?: ?:D  6v v vr" " "J! ! !H! ! !HN N N N N N N N N Nr   