Ë
    ¡[;j—  ã                  ód   — d dl mZ d dlmZ d dlmZmZ dddœd„Zdddœd„Zdddœd„Z	dddœd	„Z
y)
é    )Úannotations)Úconv_sequences)Úis_noneÚsetupPandasN)Ú	processorÚscore_cutoffc               ó¾   — |� || «      }  ||«      }t        | |«      \  } }t        t        | «      t        |«      «      }t        | |«      }||z
  }|�||k  r|S |dz   S )aî  
    Calculates the Prefix distance between two strings.

    Parameters
    ----------
    s1 : Sequence[Hashable]
        First string to compare.
    s2 : Sequence[Hashable]
        Second string to compare.
    processor: callable, optional
        Optional callable that is used to preprocess the strings before
        comparing them. Default is None, which deactivates this behaviour.
    score_cutoff : int or None, optional
        Maximum distance between s1 and s2, that is
        considered as a result. If the distance is bigger than score_cutoff,
        score_cutoff + 1 is returned instead. Default is None, which deactivates
        this behaviour.

    Returns
    -------
    distance : int
        distance between s1 and s2
    é   )r   ÚmaxÚlenÚ
similarity)Ús1Ús2r   r   ÚmaximumÚsimÚdists          úeG:\00. PROJECTS\API\Inventory\templateJSON\kerjaOCR\Lib\site-packages\rapidfuzz/distance/Prefix_py.pyÚdistancer   	   sr   € ð< ÐÙ�r‹]ˆÙ�r‹]ˆä˜B Ó#�F€BˆÜ”#�b“'œ3˜r›7Ó#€GÜ
�R˜Ó
€CØ�S‰=€Dà Ð(¨D°LÒ,@ˆ4ÐWÀ|ÐVWÑGWÐWó    c               óž   — |� || «      }  ||«      }t        | |«      \  } }d}t        | |«      D ]  \  }}||k7  r n|dz  }Œ |�||k\  r|S dS )a  
    Calculates the prefix similarity between two strings.

    This is calculated as ``len1 - distance``.

    Parameters
    ----------
    s1 : Sequence[Hashable]
        First string to compare.
    s2 : Sequence[Hashable]
        Second string to compare.
    processor: callable, optional
        Optional callable that is used to preprocess the strings before
        comparing them. Default is None, which deactivates this behaviour.
    score_cutoff : int, optional
        Maximum distance between s1 and s2, that is
        considered as a result. If the similarity is smaller than score_cutoff,
        0 is returned instead. Default is None, which deactivates
        this behaviour.

    Returns
    -------
    distance : int
        distance between s1 and s2
    r   r
   )r   Úzip)r   r   r   r   r   Úch1Úch2s          r   r   r   3   sr   € ð@ ÐÙ�r‹]ˆÙ�r‹]ˆä˜B Ó#�F€BˆØ
€CÜ˜˜B–K‰ˆˆSØ�#Š:ÙØˆq‰‰ð  ð
  Ð'¨3°,Ò+>ˆ3ÐFÀQÐFr   c               ó€   — t        «        t        | «      st        |«      ryt        | ||¬«      }d|z
  }|�||k  r|S dS )a3  
    Calculates a normalized prefix similarity in the range [1, 0].

    This is calculated as ``distance / (len1 + len2)``.

    Parameters
    ----------
    s1 : Sequence[Hashable]
        First string to compare.
    s2 : Sequence[Hashable]
        Second string to compare.
    processor: callable, optional
        Optional callable that is used to preprocess the strings before
        comparing them. Default is None, which deactivates this behaviour.
    score_cutoff : float, optional
        Optional argument for a score threshold as a float between 0 and 1.0.
        For norm_dist > score_cutoff 1.0 is returned instead. Default is 1.0,
        which deactivates this behaviour.

    Returns
    -------
    norm_dist : float
        normalized distance between s1 and s2 as a float between 0 and 1.0
    ç      ð?)r   )r   r   Únormalized_similarity)r   r   r   r   Únorm_simÚ	norm_dists         r   Únormalized_distancer   a   sH   € ô> „MÜˆr„{”g˜b”kØä$ R¨°yÔA€HØ�h‘€Ià%Ð-°¸lÒ1Jˆ9ÐTÐQTÐTr   c               ó  — t        «        t        | «      st        |«      ry|� || «      }  ||«      }t        | |«      \  } }t        t	        | «      t	        |«      «      }t        | |«      }|r||z  nd}|�||k\  r|S dS )a-  
    Calculates a normalized prefix similarity in the range [0, 1].

    This is calculated as ``1 - normalized_distance``

    Parameters
    ----------
    s1 : Sequence[Hashable]
        First string to compare.
    s2 : Sequence[Hashable]
        Second string to compare.
    processor: callable, optional
        Optional callable that is used to preprocess the strings before
        comparing them. Default is None, which deactivates this behaviour.
    score_cutoff : float, optional
        Optional argument for a score threshold as a float between 0 and 1.0.
        For norm_sim < score_cutoff 0 is returned instead. Default is 0,
        which deactivates this behaviour.

    Returns
    -------
    norm_sim : float
        normalized similarity between s1 and s2 as a float between 0 and 1.0
    g        r   )r   r   r   r   r   r   )r   r   r   r   r   r   r   s          r   r   r   Š   s…   € ô> „MÜˆr„{”g˜b”kØàÐÙ�r‹]ˆÙ�r‹]ˆä˜B Ó#�F€BˆÜ”#�b“'œ3˜r›7Ó#€GÜ
�R˜Ó
€CÙ 'ˆs�WŠ}¨S€Hà$Ð,°¸LÒ0Hˆ8ÐRÈsÐRr   )Ú
__future__r   Úrapidfuzz._common_pyr   Úrapidfuzz._utilsr   r   r   r   r   r   © r   r   Ú<module>r%      sK   ðõ #å /ß 1ð Øô'Xð\ Øô+Gðd Øô&UðZ Øõ,Sr   