
    Ah
                     :    S SK r S SKJr  S SKJr   " S S\5      rg)    N)Any)StringEvaluatorc            	          ^  \ rS rSrSrSSSS.S\S\S\S\4U 4S	 jjjr\S
\4S j5       r	\S
\4S j5       r
\S
\\   4S j5       r\S
\4S j5       rS\S\S\S
\4S jrSrU =r$ )ExactMatchStringEvaluator   a  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                F   > [         TU ]  5         Xl        X l        X0l        g )N)super__init__r   r	   r
   )selfr   r	   r
   r   	__class__s        ]/var/www/html/shao/venv/lib/python3.13/site-packages/langchain/evaluation/exact_match/base.pyr   "ExactMatchStringEvaluator.__init__   s"     	&"4,    returnc                     g)z(
This evaluator does not require input.
F r   s    r   requires_input(ExactMatchStringEvaluator.requires_input%   s    
 r   c                     g)z&
This evaluator requires a reference.
Tr   r   s    r   requires_reference,ExactMatchStringEvaluator.requires_reference,   s    
 r   c                 
    SS/$ )z>
Get the input keys.

Returns:
    List[str]: The input keys.
	reference
predictionr   r   s    r   
input_keys$ExactMatchStringEvaluator.input_keys3   s     \**r   c                     g)zB
Get the evaluation name.

Returns:
    str: The evaluation name.
exact_matchr   r   s    r   evaluation_name)ExactMatchStringEvaluator.evaluation_name=   s     r   r   r   c                f   U R                   (       a   UR                  5       nUR                  5       nU R                  (       ah  UR                  [        R                  SS[        R                  5      5      nUR                  [        R                  SS[        R                  5      5      nU R                  (       ah  UR                  [        R                  SS[        R                  5      5      nUR                  [        R                  SS[        R                  5      5      nS[        X:H  5      0$ )z
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_strings+ExactMatchStringEvaluator._evaluate_stringsG   s    " #))+J!)I""#--cmmBFDVDV.WXJ!++CMM"b&BTBT,UVI#--cmmBFMM.RSJ!++CMM"b&--,PQIZ4566r   )r   r
   r	   )__name__
__module____qualname____firstlineno____doc__boolr   r   propertyr   r   listr+   r    r$   dictr1   __static_attributes____classcell__)r   s   @r   r   r      s    & "#($- - !	-
 - - -    D   +DI + +   7 7 	7
 7 
7 7r   r   )r-   typingr   langchain.evaluation.schemar   r   r   r   r   <module>r@      s      7Z7 Z7r   