a
    •˜ëja  ã                   @   s@   d dl Z d dlmZ d dlmZ d dlmZ G dd„ deƒZdS )é    N)ÚAny)Úoverride)Ú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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   Ú_c                   s    t ƒ  ¡  || _|| _|| _dS )a–  Initialize the ExactMatchStringEvaluator.

        Args:
            ignore_case: Whether to ignore case when comparing strings.
                Defaults to False.
            ignore_punctuation: Whether to ignore punctuation when comparing strings.
                Defaults to False.
            ignore_numbers: Whether to ignore numbers when comparing strings.
                Defaults to False.
        N)ÚsuperÚ__init__r   r   r   )Úselfr   r   r   r	   ©Ú	__class__© úd/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/langchain/evaluation/exact_match/base.pyr      s    
z"ExactMatchStringEvaluator.__init__)Úreturnc                 C   s   dS )z&This evaluator does not require input.Fr   ©r   r   r   r   Úrequires_input1   s    z(ExactMatchStringEvaluator.requires_inputc                 C   s   dS )z$This evaluator requires a reference.Tr   r   r   r   r   Úrequires_reference6   s    z,ExactMatchStringEvaluator.requires_referencec                 C   s   ddgS )zUGet the input keys.

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

        Returns:
            str: The evaluation name.
        Zexact_matchr   r   r   r   r   Úevaluation_nameD   s    z)ExactMatchStringEvaluator.evaluation_name)r   r   Úkwargsr   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 )a@  Evaluate the exact match between the prediction and the reference.

        Args:
            prediction: The prediction string.
            reference: The reference string.
            **kwargs: Additional keyword arguments (not used).

        Returns:
            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_stringsM   s    z+ExactMatchStringEvaluator._evaluate_strings)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úboolr   r   Úpropertyr   r   Úlistr   r   r   r   Údictr#   Ú__classcell__r   r   r   r   r   	   s0   ûúúr   )r   Útypingr   Ztyping_extensionsr   Zlangchain.evaluation.schemar   r   r   r   r   r   Ú<module>   s   