Ë
    ¡[;j±  ã                  ó|   — d dl mZ d dlmZ d dlmZmZ d„ Zd„ Zd„ 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                óP   — |dz  }d}||| z  z  }|||z  z  }|||z
  |z  z  }|dz  S )Né   ç        g      @© )Úpattern_lenÚtext_lenÚcommon_charsÚtranspositionsÚsims        úcG:\00. PROJECTS\API\Inventory\templateJSON\kerjaOCR\Lib\site-packages\rapidfuzz/distance/Jaro_py.pyÚ_jaro_calculate_similarityr   	   sM   € Ø�qÑ€NØ
€CØˆ<˜+Ñ%Ñ%€CØˆ<˜(Ñ"Ñ"€CØˆL˜>Ñ)¨\Ñ9Ñ9€CØ�‰9Ðó    c                óF   — | r|syt        | |t        | |«      d«      }||k\  S )zC
    filter matches below score_cutoff based on string lengths
    Fr   )r   Úmin)r   r   Úscore_cutoffr   s       r   Ú_jaro_length_filterr      s/   € ñ ™hØä
$ [°(¼CÀÈXÓ<VÐXYÓ
Z€CØ�,ÑÐr   c                ó.   — |syt        | ||d«      }||k\  S )zY
    filter matches below score_cutoff based on string lengths and common characters
    Fr   )r   )r   r   r   r   r   s        r   Ú_jaro_common_char_filterr      s%   € ñ Øä
$ [°(¸LÈ!Ó
L€CØ�,ÑÐr   c                ó¨   — t        | «      }t        |«      }d}||kD  r|dz  dz
  }|||z   kD  r!|d||z    }n|dz  dz
  }|||z   kD  r| d||z    } | ||fS )zB
    find bounds and skip out of bound parts of the sequences
    r   r   é   N)Úlen)Ús1Ús2r   r   Úbounds        r   Ú_jaro_boundsr   (   sŒ   € ô �b“'€KÜ�2‹w€Hð €EØ�+ÒØ˜A‘ Ñ!ˆØ�k EÑ)Ò)ØÐ)�k EÑ)Ð*‰Bà˜qÑ  1Ñ$ˆØ˜ EÑ)Ò)ØÐ&�h Ñ&Ð'ˆBØˆr�5ˆ=Ðr   N©Ú	processorr   c               óð  — t        «        t        | «      st        |«      ry|� || «      }  ||«      }| s|sy|€d}t        | |«      \  } }t        | «      }t        |«      }t	        |||«      sy|dk(  r|dk(  rt        | d   |d   k(  «      S t        | |«      \  } }}dg|z  }dg|z  }d}	t        | «      D ]Y  \  }
}t        d|
|z
  «      }t        |
|z   |dz
  «      }t        ||dz   «      D ]!  }||   rŒ	||   |k(  sŒdx||
<   ||<   |	dz  }	 ŒY Œ[ t        |||	|«      sydx}}t        |«      D ]6  \  }
}|sŒ	t        ||«      D ]  }||   sŒ	|dz   } n | |
   |   k7  sŒ2|dz  }Œ8 t        |||	|«      S )aÍ  
    Calculates the jaro similarity

    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 ratio < score_cutoff 0 is returned instead. Default is None,
        which deactivates this behaviour.

    Returns
    -------
    similarity : float
        similarity between s1 and s2 as a float between 0 and 1.0
    r	   ç      ð?r   r   FT)r   r   r   r   r   Úfloatr   Ú	enumerateÚmaxr   Úranger   r   )r   r   r!   r   r   r   r   Ús1_flagsÚs2_flagsr   ÚiÚs1_chÚlowÚhiÚjÚkÚtrans_countÚs1_fs                     r   Ú
similarityr2   =   sÏ  € ô: „MÜˆr„{”g˜b”kØàÐÙ�r‹]ˆÙ�r‹]ˆá‘bØàÐØˆä˜B Ó#�F€BˆÜ�b“'€KÜ�2‹w€Hô ˜{¨H°lÔCØà�aÒ˜H¨šMÜ�R˜‘U˜b ™e‘^Ó$Ð$ä   RÓ(�M€BˆˆEàˆw˜Ñ$€HØˆw˜Ñ!€Hð €LÜ˜b–M‰ˆˆ5Ü�!�Q˜‘YÓˆÜ��U‘˜H q™LÓ)ˆÜ�s˜B ™FÖ#ˆAØ˜A“; 2 a¡5¨E£>Ø,0Ð0�˜‘˜h q™kØ Ñ!�Ùñ	 $ð "ô $ K°¸<ÈÔVØð Ð€AˆÜ˜XÖ&‰ˆˆ4ÚÜ˜1˜hÖ'�Ø˜A“;Ø˜A™�AÙð (ð �!‰u˜˜1™‹~Ø˜qÑ ‘ð 'ô & k°8¸\È;ÓWÐWr   c               ó    — t        | |||¬«      S )aî  
    Calculates the normalized jaro similarity

    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 ratio < score_cutoff 0 is returned instead. Default is None,
        which deactivates this behaviour.

    Returns
    -------
    normalized similarity : float
        normalized similarity between s1 and s2 as a float between 0 and 1.0
    r    )r2   ©r   r   r!   r   s       r   Únormalized_similarityr5   —   s   € ô: �b˜"¨	ÀÔMÐMr   c               óÀ   — t        «        t        | «      st        |«      ry|� || «      }  ||«      }|�|dkD  rdnd|z
  }t        | ||¬«      }d|z
  }|�||k  r|S dS )aÉ  
    Calculates the jaro 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 ratio < score_cutoff 0 is returned instead. Default is None,
        which deactivates this behaviour.

    Returns
    -------
    distance : float
        distance between s1 and s2 as a float between 1.0 and 0.0
    r#   N)r   )r   r   r2   )r   r   r!   r   Úcutoff_distancer   Údists          r   Údistancer9   ·   sy   € ô: „MÜˆr„{”g˜b”kØàÐÙ�r‹]ˆÙ�r‹]ˆà+Ð3°|ÀcÒ7I‘dÐPSÐVbÑPb€OÜ
�R˜¨/Ô
:€CØ�‰9€DØ Ð(¨D°LÒ,@ˆ4ÐJÀsÐJr   c               ó    — t        | |||¬«      S )aê  
    Calculates the normalized jaro 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 ratio < score_cutoff 0 is returned instead. Default is None,
        which deactivates this behaviour.

    Returns
    -------
    normalized distance : float
        normalized distance between s1 and s2 as a float between 1.0 and 0.0
    r    )r9   r4   s       r   Únormalized_distancer;   â   s   € ô: �B˜ i¸lÔKÐKr   )Ú
__future__r   Úrapidfuzz._common_pyr   Úrapidfuzz._utilsr   r   r   r   r   r   r2   r5   r9   r;   r
   r   r   Ú<module>r?      s`   ðõ #å /ß 1òòòòð2 ØôWXð| ØôNðH Øô(Kð^ ØõLr   