a
    aŠÝg¿
  ã                   @   s8   d dl Z d dlmZmZ d dlmZ G dd„ deƒZdS )é    N)ÚAnyÚList)ÚStringEvaluatorc                       s–   e Zd ZdZddddœeeeedœ‡ fdd„Zeedœdd	„ƒZeedœd
d„ƒZ	ee
e dœdd„ƒZeedœdd„ƒZeeeedœdd„Z‡  ZS )ÚExactMatchStringEvaluatoraÕ  Compute an exact match between the prediction and the reference.

    Examples
    ----------
    >>> evaluator = ExactMatchChain()
    >>> evaluator.evaluate_strings(
            prediction="Mindy is the CTO",
            reference="Mindy is the CTO",
        )  # This will return {'score': 1.0}

    >>> evaluator.evaluate_strings(
            prediction="Mindy is the CTO",
            reference="Mindy is the CEO",
        )  # This will return {'score': 0.0}
    F)Úignore_caseÚignore_punctuationÚignore_numbers)r   r   r   Úkwargsc                   s    t ƒ  ¡  || _|| _|| _d S )N)ÚsuperÚ__init__r   r   r   )Úselfr   r   r   r	   ©Ú	__class__© ús/var/www/html/cobodadashboardai.evdpl.com/venv/lib/python3.9/site-packages/langchain/evaluation/exact_match/base.pyr      s    
z"ExactMatchStringEvaluator.__init__)Úreturnc                 C   s   dS )z8
        This evaluator does not require input.
        Fr   ©r   r   r   r   Úrequires_input%   s    z(ExactMatchStringEvaluator.requires_inputc                 C   s   dS )z6
        This evaluator requires a reference.
        Tr   r   r   r   r   Úrequires_reference,   s    z,ExactMatchStringEvaluator.requires_referencec                 C   s   ddgS )z^
        Get the input keys.

        Returns:
            List[str]: The input keys.
        Ú	referenceÚ
predictionr   r   r   r   r   Ú
input_keys3   s    z$ExactMatchStringEvaluator.input_keysc                 C   s   dS )zb
        Get the evaluation name.

        Returns:
            str: The evaluation name.
        Zexact_matchr   r   r   r   r   Úevaluation_name=   s    z)ExactMatchStringEvaluator.evaluation_name)r   r   r	   r   c                K   sŠ   | j r| ¡ }| ¡ }| jrH| t ddtj¡¡}| t ddtj¡¡}| jrz| t ddtj	¡¡}| t ddtj	¡¡}dt
||kƒiS )a0  
        Evaluate the exact match between the prediction and the reference.

        Args:
            prediction (str): The prediction string.
            reference (Optional[str], optional): The reference string.

        Returns:
            dict: The evaluation results containing the score.
        Ú Zscore)r   Úlowerr   Ú	translateÚstrÚ	maketransÚstringÚpunctuationr   ÚdigitsÚint)r   r   r   r	   r   r   r   Ú_evaluate_stringsG   s    z+ExactMatchStringEvaluator._evaluate_strings)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úboolr   r   Úpropertyr   r   r   r   r   r   Údictr"   Ú__classcell__r   r   r   r   r      s.   ûú	úr   )r   Útypingr   r   Zlangchain.evaluation.schemar   r   r   r   r   r   Ú<module>   s   