
    gN                     $    d dl mZ  G d d      Zy)    )defaultdictc                   :    e Zd ZdZd	dZd Zd
dZddZd Zd Z	y)
MinimalSeta  
    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'.
    Nc                     t               | _        t               | _        t        t               | _        i | _        |r|D ]  \  }}}| j                  |||        yy)z
        Create a new minimal set.

        :param parameters: The (context, target, display) tuples for the item
        :type parameters: list(tuple(str, str, str))
        N)set_targets	_contextsr   _seen	_displaysadd)self
parameterscontexttargetdisplays        I/var/www/openai/venv/lib/python3.12/site-packages/nltk/misc/minimalset.py__init__zMinimalSet.__init__   sR      %
,6(&'2 -7     c                     | j                   |   j                  |       | j                  j                  |       | j                  j                  |       || j                  ||f<   y)a  
        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   s       r   r   zMinimalSet.add&   sV     	

7' 	7#&! -4()r   c                 x    | j                   D cg c]   }t        | j                  |         |k\  s|" c}S c c}w )z
        Determine which contexts occurred with enough distinct targets.

        :param minimum: the minimum number of distinct target forms
        :type minimum: int
        :rtype: list
        )r	   lenr
   )r   minimumcs      r   contextszMinimalSet.contexts<   s4      >>K>aSA-?7-J>KKKs    77c                 H    ||f| j                   v r| j                   ||f   S |S N)r   )r   r   r   defaults       r   r   zMinimalSet.displayF   s,    V.>>7F"344Nr   c                 x    g }| j                   D ](  }| j                  ||      }|s|j                  |       * |S r   )r   r   append)r   r   resultr   xs        r   display_allzMinimalSet.display_allL   s;    mmFWf-Aa  $ r   c                     | j                   S r   )r   )r   s    r   targetszMinimalSet.targetsT   s    }}r   r   )   ) )
__name__
__module____qualname____doc__r   r   r   r   r"   r$    r   r   r   r      s&    3 4,Lr   r   N)collectionsr   r   r+   r   r   <module>r-      s    $J Jr   