o
    wi                     @   s   d dl m Z  dddZdS )    )arrayFc           
         s$  t t |}}g d  }||k r|}||}}tdt|}t|D ]L}t|D ]E}|| }	| || krm|dksD|dkrId||< n|d ||< ||  kr_||  ||fgn||  krl||f nd||< |	}q.q(|r t fddD fS t fddD S )a  Find the longest common substring(s) in the sequences `seq1` and `seq2`.
	
	If positions evaluates to `True` only their positions will be returned,
	together with their length, in a tuple:
	
		(length, [(start pos in seq1, start pos in seq2)..])
	
	Otherwise, the substrings themselves will be returned, in a set.
	
	Example:
	
		>>> lcsubstrings("sedentar", "dentist")
		{'dent'}
		>>> lcsubstrings("sedentar", "dentist", positions=True)
		(4, [(2, 0)])
	r   L   c                 3   s0    | ]\}}r|  d  |  d  fV  qdS r   N ).0ij)mlenmsr   S/home/ubuntu/sommelier/.venv/lib/python3.10/site-packages/distance/_lcsubstrings.py	<genexpr>2      . zlcsubstrings.<locals>.<genexpr>c                 3   s0    | ]\}}r|  d  |d   V  qdS r   r   )r   r   _r
   r   seq1r   r   r   3   r   )lenr   rangeappendtupleset)
r   seq2	positionsL1L2lastcolumnr   r	   oldr   r   r   lcsubstrings   s4   


r   N)F)r   r   r   r   r   r   <module>   s   