§
    ™Štj÷	  ã                   óN   — d dl Z d dlmZ d dlmZ d dlmZ  G d„ de¦  «        ZdS )é    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                óV   •— t          ¦   «                              ¦   «          || _        dS )zŒInitialize 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/html/CA-Chatbot/venv/lib/python3.11/site-packages/langchain_classic/evaluation/regex_match/base.pyr   z"RegexMatchStringEvaluator.__init__    s&   ø€ õ 	‰Œ×ÒÑÔÐØˆŒ
ˆ
ˆ
ó    Úreturnc                 ó   — dS )z&This evaluator does not require input.F© ©r   s    r   Úrequires_inputz(RegexMatchStringEvaluator.requires_input)   s	   € ð ˆur   c                 ó   — dS )z$This evaluator requires a reference.Tr   r   s    r   Úrequires_referencez,RegexMatchStringEvaluator.requires_reference.   s	   € ð ˆtr   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                 ó   — dS )zTGet the evaluation name.

        Returns:
            The evaluation name.
        Úregex_matchr   r   s    r   Úevaluation_namez)RegexMatchStringEvaluator.evaluation_name<   s	   € ð ˆ}r   r   r   Úkwargsc                óv   — 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   s5   € õ$ ”˜ J°d´jÐAÑAÔAˆØ��T %™[œ[Ñ)Ô)Ð*Ð*r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r%   r   r   Úpropertyr&   r   r   ÚlistÚstrr   r   r   Údictr'   Ú__classcell__)r   s   @r   r   r   	   sL  ø€ € € € € ðð ð, ()ð ð ð  ð ¨sð ð ð ð ð ð ð ð ð ð ð ñ „Xðð ð Dð ð ð ñ „Xðð ð+˜D œIð +ð +ð +ñ „Xð+ð ð ð ð ð ñ „Xðð ð+ð ð+ð ð	+ð
 ð+ð 
ð+ð +ð +ñ „Xð+ð +ð +ð +ð +r   r   )r#   Útypingr   Útyping_extensionsr   Ú#langchain_classic.evaluation.schemar   r   r   r   r   ú<module>r4      s‚   ðØ 	€	€	€	Ø Ð Ð Ð Ð Ð à &Ð &Ð &Ð &Ð &Ð &à ?Ð ?Ð ?Ð ?Ð ?Ð ?ðO+ð O+ð O+ð O+ð O+ ñ O+ô O+ð O+ð O+ð O+r   