U
    L¬Üeý  ã                   @   s   d dl mZ ddd„ZdS )é    )ÚwordnetNc                    sV   t | ƒ‰ |dkrt |¡}ˆr0‡fdd„|D ƒ}|s8dS t‡ fdd„|D ƒƒ\}}|S )aÝ  Return a synset for an ambiguous word in a context.

    :param iter context_sentence: The context sentence where the ambiguous word
         occurs, passed as an iterable of words.
    :param str ambiguous_word: The ambiguous word that requires WSD.
    :param str pos: A specified Part-of-Speech (POS).
    :param iter synsets: Possible synsets of the ambiguous word.
    :return: ``lesk_sense`` The Synset() object with the highest signature overlaps.

    This function is an implementation of the original Lesk algorithm (1986) [1].

    Usage example::

        >>> lesk(['I', 'went', 'to', 'the', 'bank', 'to', 'deposit', 'money', '.'], 'bank', 'n')
        Synset('savings_bank.n.02')

    [1] Lesk, Michael. "Automatic sense disambiguation using machine
    readable dictionaries: how to tell a pine cone from an ice cream
    cone." Proceedings of the 5th Annual International Conference on
    Systems Documentation. ACM, 1986.
    https://dl.acm.org/citation.cfm?id=318728
    Nc                    s    g | ]}t | ¡ ƒˆ kr|‘qS © )ÚstrÚpos©Ú.0Úss)r   r   úg/mounts/lovelace/software/anaconda3/envs/qiime2-amplicon-2024.2/lib/python3.8/site-packages/nltk/wsd.pyÚ
<listcomp>*   s      zlesk.<locals>.<listcomp>c                 3   s(   | ] }t ˆ  | ¡  ¡ ¡ƒ|fV  qd S )N)ÚlenÚintersectionZ
definitionÚsplitr   )Úcontextr   r	   Ú	<genexpr>/   s    zlesk.<locals>.<genexpr>)Úsetr   ÚsynsetsÚmax)Zcontext_sentenceZambiguous_wordr   r   Ú_Zsenser   )r   r   r	   Úlesk   s    
ÿr   )NN)Znltk.corpusr   r   r   r   r   r	   Ú<module>
   s   