o
    wi                     @   s   dddZ dS )Fc                 C   sB  d\}}}t | t |}}||k r||}}|| } }|| }|dkr0|| || || f}	n|dkr=|| || f}	n|dkrG|| f}	ndS d}
|	D ]}d } }}||k r||k r| | || kr|d }d|k rnni|r|dkr||d k r||d k r| |d  || kr| | ||d  kr|d |d }}n1||d  }||kr|d }n"||kr|d }n||ksJ |d |d }}n	|d |d }}||k r||k s]d|k rqM||k r|| ||d |kr|||  }nqM||k r|| ||d |kr|||  }nqM||
k r|}
qM|
dkrd}
|
S )a  Compute the distance between the two sequences `seq1` and `seq2` up to a
	maximum of 2 included, and return it. If the edit distance between the two
	sequences is higher than that, -1 is returned.
	
	If `transpositions` is `True`, transpositions will be taken into account for
	the computation of the distance. This can make a difference, e.g.:

		>>> fast_comp("abc", "bac", transpositions=False)
		2
		>>> fast_comp("abc", "bac", transpositions=True)
		1
	
	This is faster than `levenshtein` by an order of magnitude, but on the
	other hand is of limited use.

	The algorithm comes from `http://writingarchives.sakura.ne.jp/fastcomp`.
	I've added transpositions support to the original code.
	)rid             N)lencount)seq1seq2transpositionsreplaceinsertdeleteL1L2ldiffmodelsresmodelr   jccmd r   O/home/ubuntu/sommelier/.venv/lib/python3.10/site-packages/distance/_fastcomp.py	fast_comp   sd   


(




r   N)F)r   r   r   r   r   <module>   s   