ณ๒
4าวIc           @   s   d  e  f d     YZ d S(   t
   MinimalSetc           B   sM   e  Z d  Z e 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   sl   t    |  _ t    |  _ t t   |  _ h  |  _ | o1 x. | D]" \ } } } |  i | | |  q> Wn d S(   sต   
        Create a new minimal set.

        @param parameters: The (context, target, display) tuples for the item
        @type parameters: C{list} of C{tuple} of C{string}
        N(   t   sett   _targetst	   _contextst   defaultdictt   _seent	   _displayst   add(   t   selft
   parameterst   contextt   targett   display(    (    s*   /p/zhu/06/nlp/nltk/nltk/misc/minimalset.pyt   __init__   s    	 c         C   sK   |  i  | i |  |  i i |  |  i i |  | |  i | | 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: C{string}
        @param target: The item of interest
        @type target: C{string}
        @param display: The information to be reported for each item
        @type display: C{string}
        N(   R   R   R   R   R   (   R   R
   R   R   (    (    s*   /p/zhu/06/nlp/nltk/nltk/misc/minimalset.pyR   #   s    i   c         C   s@   g  } |  i  D]+ } t |  i |  | j o | | q q ~ S(   sห   
        Determine which contexts occurred with enough distinct targets.

        @param minimum: the minimum number of distinct target forms
        @type minimum: C{int}
        @rtype C{list}
        (   R   t   lenR   (   R   t   minimumt   _[1]t   c(    (    s*   /p/zhu/06/nlp/nltk/nltk/misc/minimalset.pyt   contexts9   s    t    c         C   s3   | | f |  i  j o |  i  | | f Sn | Sd  S(   N(   R   (   R   R
   R   t   default(    (    s*   /p/zhu/06/nlp/nltk/nltk/misc/minimalset.pyR   C   s    c         C   sH   g  } x; |  i  D]0 } |  i | |  } | o | i |  q q W| S(   N(   R   R   t   append(   R   R
   t   resultR   t   x(    (    s*   /p/zhu/06/nlp/nltk/nltk/misc/minimalset.pyt   display_allI   s    
 c         C   s   |  i  S(   N(   R   (   R   (    (    s*   /p/zhu/06/nlp/nltk/nltk/misc/minimalset.pyt   targetsP   s    (
   t   __name__t
   __module__t   __doc__t   NoneR   R   R   R   R   R   (    (    (    s*   /p/zhu/06/nlp/nltk/nltk/misc/minimalset.pyR    	   s   		
	N(   t   objectR    (    (    (    s*   /p/zhu/06/nlp/nltk/nltk/misc/minimalset.pys   <module>	   s    