o
    Jjg¿
  ã                   @   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œdedededef‡ fdd	„Zed
efdd„ƒZed
efdd„ƒZ	ed
e
e fdd„ƒZed
efdd„ƒZdededed
ef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_numbersr   r   r   Úkwargsc                   s    t ƒ  ¡  || _|| _|| _d S )N)ÚsuperÚ__init__r   r   r   )Úselfr   r   r   r	   ©Ú	__class__© ú]/var/www/html/zoom/venv/lib/python3.10/site-packages/langchain/evaluation/exact_match/base.pyr      s   

z"ExactMatchStringEvaluator.__init__Úreturnc                 C   ó   dS )z8
        This evaluator does not require input.
        Fr   ©r   r   r   r   Úrequires_input%   ó   z(ExactMatchStringEvaluator.requires_inputc                 C   r   )z6
        This evaluator requires a reference.
        Tr   r   r   r   r   Úrequires_reference,   r   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   r   )zb
        Get the evaluation name.

        Returns:
            str: The evaluation name.
        Úexact_matchr   r   r   r   r   Úevaluation_name=   s   z)ExactMatchStringEvaluator.evaluation_namer   r   c                K   sŠ   | j r| ¡ }| ¡ }| jr$| t ddtj¡¡}| t ddtj¡¡}| jr=| 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.
        Ú Ú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   Úlangchain.evaluation.schemar   r   r   r   r   r   Ú<module>   s    