o
    5tiw
                     @   sL   d dl mZmZ d dlmZ ddlmZ ddlmZ dZ	G dd deZ
d	S )
    )DictTuple)Dataset   )	Evaluator)DatasetColumna=  
        input_column (`str`, defaults to `"text"`):
            the name of the column containing the input text in the dataset specified by `data`.
        generation_kwargs (`Dict`, *optional*, defaults to `None`):
            The generation kwargs are passed to the pipeline and set the text generation strategy.
c                       sN   e Zd ZdZdd Zddef fdd	Zd
ededee	e
f fddZ  ZS )TextGenerationEvaluatora  
    Text generation evaluator.
    This Text generation evaluator can currently be loaded from [`evaluator`] using the default task name
    `text-generation`.
    Methods in this class assume a data format compatible with the [`~transformers.TextGenerationPipeline`].
    c                    s   d fdd|D iS )z
        Args:
            predictions: A list of lists of dicts

        Returns:
            `dict`: All the generated texts are flattened and stored under the "data" key.
        datac                    s&   g | ]}|D ]
}| j  d  qqS )_text)predictions_prefix).0	pred_listpredself V/home/ubuntu/.local/lib/python3.10/site-packages/evaluate/evaluator/text_generation.py
<listcomp>/   s   & zATextGenerationEvaluator.predictions_processor.<locals>.<listcomp>r   )r   predictionsargskwargsr   r   r   predictions_processor'   s   z-TextGenerationEvaluator.predictions_processortext-generationN	generatedr   c                    s   t  j||d || _d S )N)taskdefault_metric_name)super__init__r   )r   r   r   r   	__class__r   r   r   1   s   
z TextGenerationEvaluator.__init__r	   input_columnreturnc                 O   s   |  |d|i i t||fS )a  
        Prepare data.

        Args:
            data ([`Dataset`]):
                Specifies the dataset we will run evaluation on.
            input_column (`str`, defaults to `"text"`):
                The name of the column containing the text feature in the dataset specified by `data`.
        Returns:
            `dict`:  metric inputs.
            `list`:  pipeline inputs.
        r    )check_required_columnsr   )r   r	   r    r   r   r   r   r   prepare_data5   s   z$TextGenerationEvaluator.prepare_data)r   Nr   )__name__
__module____qualname____doc__r   strr   r   r   r   r   r#   __classcell__r   r   r   r   r      s
    
&r   N)typingr   r   datasetsr   baser   utilsr   TASK_DOCUMENTATION_KWARGSr   r   r   r   r   <module>   s   