
    ih
                     >    d dl Z d dlmZmZ d dlmZ  G d de      Zy)    N)AnyList)StringEvaluatorc            	            e Zd ZdZdddddedededef fdZed	efd
       Zed	efd       Z	ed	e
e   fd       Zed	efd       Zdededed	efdZ x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                L    t         |           || _        || _        || _        y )N)super__init__r   r	   r
   )selfr   r	   r
   r   	__class__s        c/var/www/html/dev/engine/venv/lib/python3.12/site-packages/langchain/evaluation/exact_match/base.pyr   z"ExactMatchStringEvaluator.__init__   s(     	&"4,    returnc                      y)z8
        This evaluator does not require input.
        F r   s    r   requires_inputz(ExactMatchStringEvaluator.requires_input%   s    
 r   c                      y)z6
        This evaluator requires a reference.
        Tr   r   s    r   requires_referencez,ExactMatchStringEvaluator.requires_reference,   s    
 r   c                 
    ddgS )z^
        Get the input keys.

        Returns:
            List[str]: The input keys.
        	reference
predictionr   r   s    r   
input_keysz$ExactMatchStringEvaluator.input_keys3   s     \**r   c                      y)zb
        Get the evaluation name.

        Returns:
            str: The evaluation name.
        exact_matchr   r   s    r   evaluation_namez)ExactMatchStringEvaluator.evaluation_name=   s     r   r   r   c                J   | j                   r |j                         }|j                         }| j                  rh|j                  t        j                  ddt        j                              }|j                  t        j                  ddt        j                              }| j                  rh|j                  t        j                  ddt        j                              }|j                  t        j                  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   s       r   _evaluate_stringsz+ExactMatchStringEvaluator._evaluate_stringsG   s    " #))+J!)I""#--cmmBFDVDV.WXJ!++CMM"b&BTBT,UVI#--cmmBFMM.RSJ!++CMM"b&--,PQIZ94566r   )__name__
__module____qualname____doc__boolr   r   propertyr   r   r   r&   r   r    dictr,   __classcell__)r   s   @r   r   r      s    & "#($- - !	-
 - -    D   +DI + +   7 7 	7
 7 
7r   r   )r(   typingr   r   langchain.evaluation.schemar   r   r   r   r   <module>r7      s      7Z7 Z7r   