Ë
    ¡[;j¿  ã                  ój   — d dl mZ d dlmZ d dlmZmZ d„ 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ÚsetupPandasc                óô  — t        t        | «      t        |«      «      dz   }i }|j                  }t        |«      dz   }|g|z  }|g|z  }t        t	        |«      «      }||d<   t	        dt        | «      dz   «      D ]î  }	||}}d}
|d   }|	|d<   |}t	        dt        |«      dz   «      D ]´  }||dz
     | |	dz
     ||dz
     k7  z   }||dz
     dz   }||   dz   }t        |||«      }| |	dz
     ||dz
     k(  r|}
||dz
     ||<   |}nM |||dz
     d«      }|
}||z
  dk(  r||   |	|z
  z   }t        ||«      }n|	|z
  dk(  r|||z
  z   }t        ||«      }||   }|||<   Œ¶ |	|| |	dz
     <   Œð |t        |«         S )Né   é   éÿÿÿÿr   )ÚmaxÚlenÚgetÚlistÚrangeÚmin)Ús1Ús2ÚmaxValÚlast_row_idÚlast_row_id_getÚsizeÚFRÚR1ÚRÚiÚlast_col_idÚ	last_i2l1ÚTÚjÚdiagÚleftÚupÚtempÚkÚlÚ	transposes                        úqG:\00. PROJECTS\API\Inventory\templateJSON\kerjaOCR\Lib\site-packages\rapidfuzz/distance/DamerauLevenshtein_py.pyÚ"_damerau_levenshtein_distance_zhaor'   	   sÜ  € Ü”�R“œ#˜b›'Ó" QÑ&€FØ€KØ!—o‘o€OÜˆr‹7�Q‰;€DØ
ˆ�D‰€BØ
ˆ�D‰€BÜŒU�4‹[Ó€AØ€A€b�Eä�1”c˜"“g ‘kÖ"ˆØ�Aˆ2ˆØˆØ�a‘Dˆ	Øˆˆ!‰Øˆä�qœ#˜b›' A™+Ö&ˆAØ�a˜!‘e‘9  1 q¡5¡	¨R°°A±©YÑ 6Ñ7ˆDØ�Q˜‘U‘8˜a‘<ˆDØ�A‘˜‘ˆBÜ�t˜T 2Ó&ˆDà�!�a‘%‰y˜B˜q 1™u™IÒ%Ø�Ø˜1˜q™5™	��1‘Ø‘á# B q¨1¡u¡I¨rÓ2�Ø�à˜‘E˜a’<Ø " 1¡¨¨Q©¡�IÜ˜t YÓ/‘DØ˜!‘e ’\Ø ! Q¨¡U¡�IÜ˜t YÓ/�Dà˜!™ˆIØˆAˆaŠDð- 'ð0 "#ˆ�B�q˜1‘u‘IÒð? #ðB ŒS�‹W‰:Ðó    N)Ú	processorÚscore_cutoffc               óx   — |� || «      }  ||«      }t        | |«      \  } }t        | |«      }|�||k  r|S |dz   S )a«  
    Calculates the Damerau-Levenshtein 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 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

    Examples
    --------
    Find the Damerau-Levenshtein distance between two strings:

    >>> from rapidfuzz.distance import DamerauLevenshtein
    >>> DamerauLevenshtein.distance("CA", "ABC")
    2
    r   )r   r'   )r   r   r)   r*   Údists        r&   Údistancer-   7   sV   € ðL ÐÙ�r‹]ˆÙ�r‹]ˆä˜B Ó#�F€BˆÜ-¨b°"Ó5€DØ Ð(¨D°LÒ,@ˆ4ÐWÀ|ÐVWÑGWÐWr(   c               ó¸   — |� || «      }  ||«      }t        | |«      \  } }t        t        | «      t        |«      «      }t        | |«      }||z
  }|�||k\  r|S dS )a*  
    Calculates the Damerau-Levenshtein similarity in the range [max, 0].

    This is calculated as ``max(len1, len2) - 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
    -------
    similarity : int
        similarity between s1 and s2
    r   )r   r   r   r-   )r   r   r)   r*   Úmaximumr,   Úsims          r&   Ú
similarityr1   f   sm   € ð@ ÐÙ�r‹]ˆÙ�r‹]ˆä˜B Ó#�F€BˆÜ”#�b“'œ3˜r›7Ó#€GÜ�B˜Ó€DØ
�D‰.€CØÐ'¨3°,Ò+>ˆ3ÐFÀQÐFr(   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 Damerau-Levenshtein distance in the range [1, 0].

    This is calculated as ``distance / max(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   r   r   r   r   r-   )r   r   r)   r*   r/   r,   Ú	norm_dists          r&   Únormalized_distancer5   ‘   s†   € ô> „MÜˆr„{”g˜b”kØàÐÙ�r‹]ˆÙ�r‹]ˆä˜B Ó#�F€BˆÜ”#�b“'œ3˜r›7Ó#€GÜ�B˜Ó€DÙ")��w’¨q€IØ%Ð-°¸lÒ1Jˆ9ÐRÐQRÐRr(   c               ó¾   — t        «        t        | «      st        |«      ry|� || «      }  ||«      }t        | |«      \  } }t        | |«      }d|z
  }|�||k\  r|S dS )a:  
    Calculates a normalized Damerau-Levenshtein 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        r3   r   )r   r   r   r5   )r   r   r)   r*   r4   Únorm_sims         r&   Únormalized_similarityr8   ¿   sm   € ô> „MÜˆr„{”g˜b”kØàÐÙ�r‹]ˆÙ�r‹]ˆä˜B Ó#�F€BˆÜ# B¨Ó+€IØ�Y‰€HØ$Ð,°¸LÒ0Hˆ8ÐPÈqÐPr(   )Ú
__future__r   Úrapidfuzz._common_pyr   Úrapidfuzz._utilsr   r   r'   r-   r1   r5   r8   © r(   r&   Ú<module>r=      sQ   ðõ #å /ß 1ò+ðd Øô,Xðf Øô(Gð^ Øô+Sðd Øõ*Qr(   