
    3fi	                     F    d dl Z d dlmZ d dlmZ d dlmZ  G d de      Zy)    N)Any)override)StringEvaluatorc            	            e Zd ZdZdd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ededededefd       Z xZS )RegexMatchStringEvaluatora  Compute a regex match between the prediction and the reference.

    Examples:
    ----------
    >>> evaluator = RegexMatchStringEvaluator(flags=re.IGNORECASE)
    >>> evaluator.evaluate_strings(
            prediction="Mindy is the CTO",
            reference="^mindy.*cto$",
        )  # This will return {'score': 1.0} due to the IGNORECASE flag

    >>> evaluator = RegexMatchStringEvaluator()
    >>> evaluator.evaluate_strings(
            prediction="Mindy is the CTO",
            reference="^Mike.*CEO$",
        )  # This will return {'score': 0.0}

    >>> evaluator.evaluate_strings(
            prediction="Mindy is the CTO",
            reference="^Mike.*CEO$|^Mindy.*CTO$",
        )  # This will return {'score': 1.0} as the prediction matches the second pattern in the union
    r   flagsr	   _c                0    t         |           || _        y)zInitialize the RegexMatchStringEvaluator.

        Args:
            flags: Flags to use for the regex match. Defaults to no flags.
        N)super__init__r	   )selfr	   r
   	__class__s      k/var/www/auto_recruiter/arenv/lib/python3.12/site-packages/langchain_classic/evaluation/regex_match/base.pyr   z"RegexMatchStringEvaluator.__init__    s     	
    returnc                      y)z&This evaluator does not require input.F r   s    r   requires_inputz(RegexMatchStringEvaluator.requires_input)   s     r   c                      y)z$This evaluator requires a reference.Tr   r   s    r   requires_referencez,RegexMatchStringEvaluator.requires_reference.   s     r   c                 
    ddgS )zJGet the input keys.

        Returns:
            The input keys.
        	reference
predictionr   r   s    r   
input_keysz$RegexMatchStringEvaluator.input_keys3   s     \**r   c                      y)zTGet the evaluation name.

        Returns:
            The evaluation name.
        regex_matchr   r   s    r   evaluation_namez)RegexMatchStringEvaluator.evaluation_name<   s     r   r   r   kwargsc                r    t        j                  ||| j                        }dt        t	        |            iS )aG  Evaluate the regex match between the prediction and the reference.

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

        Returns:
            The evaluation results containing the score.
        r   score)rematchr	   intbool)r   r   r   r    r$   s        r   _evaluate_stringsz+RegexMatchStringEvaluator._evaluate_stringsE   s.    $ JdjjAT%[)**r   )__name__
__module____qualname____doc__r%   r   r   propertyr&   r   r   liststrr   r   r   dictr'   __classcell__)r   s   @r   r   r   	   s    , ()  s     D   +DI + +    + + 	+
 + 
+ +r   r   )r#   typingr   typing_extensionsr   #langchain_classic.evaluation.schemar   r   r   r   r   <module>r4      s    	  & ?O+ O+r   