
    i                         d dl mZmZmZmZm	Z
mZmZmZ ddlmZ d Zd Zd ZddZddZdd	Zdd
Z	ddZddZddZddZy)    )ratiopartial_ratiotoken_set_ratiotoken_sort_ratiopartial_token_set_ratiopartial_token_sort_ratioWRatioQRatio   )utilsc                     |r3||yt        j                  ||      }t        j                  ||      }t        t         | ||                  S )zT
    wrapper around rapidfuzz function to be compatible with the API of thefuzz
    r   )force_ascii)r   full_processintround)scorers1s2r   r   s        ]/var/www/vps2.regionflexible.com/Desarrollo/venv/lib/python3.12/site-packages/thefuzz/fuzz.py_rapidfuzz_scorerr      sM     :<<uVB^$%%    c                 (    t        t        | |dd      S )NF)r   _ratior   r   s     r   r   r   #   s    VRUE::r   c                 (    t        t        | |dd      S )z[
    Return the ratio of the most similar substring
    as a number between 0 and 100.
    F)r   _partial_ratior   s     r   r   r   '   s    
 ^RUEBBr   c                 (    t        t        | |||      S )zu
    Return a measure of the sequences' similarity between 0 and 100
    but sorting the token before comparing.
    )r   _token_sort_ratior   r   r   r   s       r   r   r   7   s    
 .B\RRr   c                 (    t        t        | |||      S )z
    Return the ratio of the most similar substring as a number between
    0 and 100 but sorting the token before comparing.
    )r   _partial_token_sort_ratior   s       r   r   r   ?   s    
 !2r; r   c                 (    t        t        | |||      S N)r   _token_set_ratior   s       r   r   r   I   s    -r2{LQQr   c                 (    t        t        | |||      S r#   )r   _partial_token_set_ratior   s       r   r   r   M   s     "b+| r   c                 (    t        t        | |||      S )a  
    Quick ratio comparison between two strings.

    Runs full_process from utils on both strings
    Short circuits if either of the strings is empty after processing.

    :param s1:
    :param s2:
    :param force_ascii: Allow only ASCII characters (Default: True)
    :full_process: Process inputs, used here to avoid double processing in extract functions (Default: True)
    :return: similarity ratio
    )r   _QRatior   s       r   r
   r
   X   s     Wb"k<HHr   c                      t        | |d|      S )z
    Unicode quick ratio

    Calls QRatio with force_ascii set to False

    :param s1:
    :param s2:
    :return: similarity ratio
    Fr   r   )r
   r   r   r   s      r   UQRatior,   h   s     "be,GGr   c                 (    t        t        | |||      S )aj  
    Return a measure of the sequences' similarity between 0 and 100, using different algorithms.

    **Steps in the order they occur**

    #. Run full_process from utils on both strings
    #. Short circuit if this makes either string empty
    #. Take the ratio of the two processed strings (fuzz.ratio)
    #. Run checks to compare the length of the strings
        * If one of the strings is more than 1.5 times as long as the other
          use partial_ratio comparisons - scale partial results by 0.9
          (this makes sure only full results can return 100)
        * If one of the strings is over 8 times as long as the other
          instead scale by 0.6

    #. Run the other ratio functions
        * if using partial ratio functions call partial_ratio,
          partial_token_sort_ratio and partial_token_set_ratio
          scale all of these by the ratio based on length
        * otherwise call token_sort_ratio and token_set_ratio
        * all token based comparisons are scaled by 0.95
          (on top of any partial scalars)

    #. Take the highest value from these results
       round it and return it as an integer.

    :param s1:
    :param s2:
    :param force_ascii: Allow only ascii characters
    :type force_ascii: bool
    :full_process: Process inputs, used here to avoid double processing in extract functions (Default: True)
    :return:
    )r   _WRatior   s       r   r	   r	   v   s    D Wb"k<HHr   c                      t        | |d|      S )z
    Return a measure of the sequences' similarity between 0 and 100,
    using different algorithms. Same as WRatio but preserving unicode.
    Fr*   )r	   r+   s      r   UWRatior0      s    
 "be,GGr   N)TT)T)rapidfuzz.fuzzr   r   r   r   r   r$   r   r   r   r&   r   r!   r	   r.   r
   r(    r   r   r,   r0    r   r   <module>r4      sX   	 	 	 &;C SRI 
H"IJHr   