
    Ng
                     F    d dl Z d dlmZmZ d dlmZ  G d de          ZdS )    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                r    t                                                       || _        || _        || _        d S )N)super__init__r   r	   r
   )selfr   r	   r
   r   	__class__s        a/var/www/html/ai-engine/env/lib/python3.11/site-packages/langchain/evaluation/exact_match/base.pyr   z"ExactMatchStringEvaluator.__init__   s9     	&"4,    returnc                     dS )z8
        This evaluator does not require input.
        F r   s    r   requires_inputz(ExactMatchStringEvaluator.requires_input%   s	    
 ur   c                     dS )z6
        This evaluator requires a reference.
        Tr   r   s    r   requires_referencez,ExactMatchStringEvaluator.requires_reference,   s	    
 tr   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                     dS )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                n   | j         r(|                                }|                                }| j        rr|                    t                              ddt          j                            }|                    t                              ddt          j                            }| j        rr|                    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   s       r   _evaluate_stringsz+ExactMatchStringEvaluator._evaluate_stringsG   s    "  	*#))++J!))I" 	W#--cmmBFDV.W.WXXJ!++CMM"b&BT,U,UVVI 	R#--cmmBFM.R.RSSJ!++CMM"b&-,P,PQQIZ945566r   )__name__
__module____qualname____doc__boolr   r   propertyr   r   r   r&   r   r    dictr,   __classcell__)r   s   @r   r   r      s`        & "#($- - - - !	-
 - - - - - - -     X D    X +DI + + + X+     X7 7 	7
 7 
7 7 7 7 7 7 7 7r   r   )r(   typingr   r   langchain.evaluation.schemar   r   r   r   r   <module>r7      sv             7 7 7 7 7 7Z7 Z7 Z7 Z7 Z7 Z7 Z7 Z7 Z7 Z7r   