ó
ù`]c           @   s*   d  d l  m Z d e f d     YZ d S(   iÿÿÿÿ(   t   defaultdictt
   MinimalSetc           B   sM   e  Z d  Z d	 d  Z d   Z d d  Z d d  Z d   Z d   Z	 RS(
   s¬  
    Find contexts where more than one possible target value can
    appear.  E.g. if targets are word-initial letters, and contexts
    are the remainders of words, then we would like to find cases like
    "fat" vs "cat", and "training" vs "draining".  If targets are
    parts-of-speech and contexts are words, then we would like to find
    cases like wind (noun) 'air in rapid motion', vs wind (verb)
    'coil, wrap'.
    c         C   sj   t    |  _ t    |  _ t t   |  _ i  |  _ | rf x- | D]" \ } } } |  j | | |  q= Wn  d S(   s¯   
        Create a new minimal set.

        :param parameters: The (context, target, display) tuples for the item
        :type parameters: list(tuple(str, str, str))
        N(   t   sett   _targetst	   _contextsR    t   _seent	   _displayst   add(   t   selft
   parameterst   contextt   targett   display(    (    s3   lib/python2.7/site-packages/nltk/misc/minimalset.pyt   __init__   s    	c         C   sK   |  j  | j |  |  j j |  |  j j |  | |  j | | f <d S(   s  
        Add a new item to the minimal set, having the specified
        context, target, and display form.

        :param context: The context in which the item of interest appears
        :type context: str
        :param target: The item of interest
        :type target: str
        :param display: The information to be reported for each item
        :type display: str
        N(   R   R   R   R   R   (   R   R
   R   R   (    (    s3   lib/python2.7/site-packages/nltk/misc/minimalset.pyR   &   s    i   c         C   s3   g  |  j  D]% } t |  j |  | k r
 | ^ q
 S(   sÅ   
        Determine which contexts occurred with enough distinct targets.

        :param minimum: the minimum number of distinct target forms
        :type minimum: int
        :rtype list
        (   R   t   lenR   (   R   t   minimumt   c(    (    s3   lib/python2.7/site-packages/nltk/misc/minimalset.pyt   contexts<   s    t    c         C   s.   | | f |  j  k r& |  j  | | f S| Sd  S(   N(   R   (   R   R
   R   t   default(    (    s3   lib/python2.7/site-packages/nltk/misc/minimalset.pyR   F   s    c         C   sF   g  } x9 |  j  D]. } |  j | |  } | r | j |  q q W| S(   N(   R   R   t   append(   R   R
   t   resultR   t   x(    (    s3   lib/python2.7/site-packages/nltk/misc/minimalset.pyt   display_allL   s    c         C   s   |  j  S(   N(   R   (   R   (    (    s3   lib/python2.7/site-packages/nltk/misc/minimalset.pyt   targetsT   s    N(
   t   __name__t
   __module__t   __doc__t   NoneR   R   R   R   R   R   (    (    (    s3   lib/python2.7/site-packages/nltk/misc/minimalset.pyR      s   		
	N(   t   collectionsR    t   objectR   (    (    (    s3   lib/python2.7/site-packages/nltk/misc/minimalset.pyt   <module>   s   