o
    rZŽhN  ã                   @   s   d dl mZ G dd„ dƒZdS )é    )Údefaultdictc                   @   sF   e Zd ZdZddd„Zdd„ Zddd	„Zddd„Zdd„ Zdd„ Z	dS )Ú
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                 C   sJ   t ƒ | _t ƒ | _tt ƒ| _i | _|r!|D ]\}}}|  |||¡ qdS dS )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Údisplay© r   úC/var/www/auris/lib/python3.10/site-packages/nltk/misc/minimalset.pyÚ__init__   s   
þzMinimalSet.__init__c                 C   s:   | j |  |¡ | j |¡ | j |¡ || j||f< dS )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   r   r   r   r	   &   s   zMinimalSet.addé   c                    s   ‡ ‡fdd„ˆj D ƒS )zÆ
        Determine which contexts occurred with enough distinct targets.

        :param minimum: the minimum number of distinct target forms
        :type minimum: int
        :rtype: list
        c                    s"   g | ]}t ˆj| ƒˆ kr|‘qS r   )Úlenr   )Ú.0Úc©Úminimumr
   r   r   Ú
<listcomp>D   s   " z'MinimalSet.contexts.<locals>.<listcomp>)r   )r
   r   r   r   r   Úcontexts<   s   zMinimalSet.contextsÚ c                 C   s    ||f| j v r| j ||f S |S ©N)r   )r
   r   r   Údefaultr   r   r   r   F   s   zMinimalSet.displayc                 C   s.   g }| j D ]}|  ||¡}|r| |¡ q|S r   )r   r   Úappend)r
   r   Úresultr   Úxr   r   r   Údisplay_allL   s   

€zMinimalSet.display_allc                 C   s   | j S r   )r   )r
   r   r   r   ÚtargetsT   s   zMinimalSet.targetsr   )r   )r   )
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r	   r   r   r    r!   r   r   r   r   r      s    




r   N)Úcollectionsr   r   r   r   r   r   Ú<module>   s   