ó
ů`]c           @   s#   d  d l  m Z d d d  Z d S(   i˙˙˙˙(   t   wordnetc            s   t  |     | d k r* t j |  } n  | rd g  | D]$ } t | j    | k r7 | ^ q7 } n  | sn d St   f d   | D  \ } } | S(   sÜ  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.
    http://dl.acm.org/citation.cfm?id=318728
    c         3   s6   |  ], } t    j | j   j     | f Vq d  S(   N(   t   lent   intersectiont
   definitiont   split(   t   .0t   ss(   t   context(    s'   lib/python2.7/site-packages/nltk/wsd.pys	   <genexpr>0   s    N(   t   sett   NoneR    t   synsetst   strt   post   max(   t   context_sentencet   ambiguous_wordR   R
   R   t   _t   sense(    (   R   s'   lib/python2.7/site-packages/nltk/wsd.pyt   lesk   s    4N(   t   nltk.corpusR    R	   R   (    (    (    s'   lib/python2.7/site-packages/nltk/wsd.pyt   <module>
   s   