o
    ò³õf…	  ã                   @   s*   d Z ddlT ddlmZ G dd„ dƒZdS )z¾
StringMatcher.py

ported from python-Levenshtein
[https://github.com/miohtama/python-Levenshtein]
License available here: https://github.com/miohtama/python-Levenshtein/blob/master/COPYING
é    )Ú*)Úwarnc                   @   sr   e Zd ZdZdd„ Zdd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dd„ Zdd„ ZdS )ÚStringMatcherz<A SequenceMatcher-like class built on the top of Levenshteinc                 C   s"   d  | _ | _d  | _ | _| _d S ©N)Ú_ratioÚ	_distanceÚ_opcodesÚ_editopsÚ_matching_blocks©Úself© r   úQ/home/ubuntu/webapp/venv/lib/python3.10/site-packages/fuzzywuzzy/StringMatcher.pyÚ_reset_cache   s   zStringMatcher._reset_cacheNÚ c                 C   s&   |rt dƒ ||| _| _|  ¡  d S )Nz.isjunk not NOT implemented, it will be ignored)r   Ú_str1Ú_str2r   )r   ÚisjunkÚseq1Úseq2r   r   r   Ú__init__   s   zStringMatcher.__init__c                 C   s   ||| _ | _|  ¡  d S r   )r   r   r   )r   r   r   r   r   r   Úset_seqs   s   zStringMatcher.set_seqsc                 C   ó   || _ |  ¡  d S r   )r   r   )r   r   r   r   r   Úset_seq1    ó   zStringMatcher.set_seq1c                 C   r   r   )r   r   )r   r   r   r   r   Úset_seq2$   r   zStringMatcher.set_seq2c                 C   ó<   | j s| jrt| j| j| jƒ| _ | j S t| j| jƒ| _ | j S r   )r   r	   Úopcodesr   r   r   r   r   r   Úget_opcodes(   ó   ÿzStringMatcher.get_opcodesc                 C   r   r   )r	   r   Úeditopsr   r   r   r   r   r   Úget_editops0   r   zStringMatcher.get_editopsc                 C   s"   | j st|  ¡ | j| jƒ| _ | j S r   )r
   Úmatching_blocksr   r   r   r   r   r   r   Úget_matching_blocks8   s
   ÿz!StringMatcher.get_matching_blocksc                 C   ó   | j st| j| jƒ| _ | j S r   ©r   Úratior   r   r   r   r   r   r&   >   ó   zStringMatcher.ratioc                 C   r$   r   r%   r   r   r   r   Úquick_ratioC   s   zStringMatcher.quick_ratioc                 C   s,   t | jƒt | jƒ}}dt||ƒ ||  S )Ng       @)Úlenr   r   Úmin)r   Úlen1Úlen2r   r   r   Úreal_quick_ratioI   s   zStringMatcher.real_quick_ratioc                 C   r$   r   )r   Údistancer   r   r   r   r   r   r.   M   r'   zStringMatcher.distance)Nr   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r!   r#   r&   r(   r-   r.   r   r   r   r   r      s    
r   N)r2   ÚLevenshteinÚwarningsr   r   r   r   r   r   Ú<module>   s   