
    _j                        U d dl mZ d dlZd dlmZmZmZmZ g dZde	d<    e
e          Zde	d<    G d d	e          Z G d
 d          ZddZ G d d          Z G d d          Zg dZdS )    )annotationsN)IterableListProtocolcast)aaboutaboveafteragainagainstainallamanandanyarearenzaren'tasatbebecausebeenbeforebeingbelowbetweenbothbutbycancouldnzcouldn'tddiddidnzdidn'tdodoesdoesnzdoesn'tdoingdonzdon'tdownduringeachfewforfromfurtherhadhadnzhadn'thashasnzhasn'thavehavenzhaven'thavingheherherehersherselfhimhimselfhishowiifinintoisisnzisn'titzit'sitsitselfjustllmmamemightnzmightn'tmoremostmustnzmustn'tmymyselfneednzneedn'tnonornotnowoofoffononceonlyorotherourours	ourselvesoutoverownressameshanzshan'tshezshe'sshouldz	should'veshouldnz	shouldn'tsosomesuchtthanthatzthat'llthetheirtheirsthem
themselvesthentherethesetheythisthosethroughtotoounderuntilupveverywaswasnzwasn'twewerewerenzweren'twhatwhenwherewhichwhilewhowhomwhywillwithwonzwon'twouldnzwouldn'tyyouzyou'dzyou'llzyou'rezyou'veyouryoursyourself
yourselves	List[str]DEFAULT_ENGLISH_STOPWORDSDEFAULT_CHROMA_BM25_STOPWORDSc                      e Zd ZddZdS )SnowballStemmertokenstrreturnc                    d S N selfr   s     v/var/www/FlaskApp/flask-venv/lib/python3.11/site-packages/chromadb/utils/embedding_functions/schemas/bm25_tokenizer.pystemzSnowballStemmer.stem   s        Nr   r   r   r   )__name__
__module____qualname__r   r   r   r   r   r      s(             r   r   c                  "    e Zd ZdZd	dZd
dZdS )_SnowballStemmerAdapterzCAdapter that provides the uniform `stem` API used across languages.r   Nonec                    	 dd l }n# t          $ r t          d          w xY w|                    d          | _        d S )Nr   ziThe snowballstemmer python package is not installed. Please install it with `pip install snowballstemmer`english)snowballstemmerImportError
ValueErrorstemmer_stemmer)r   r   s     r   __init__z _SnowballStemmerAdapter.__init__   sa    	""""" 	 	 	{  	
 (//	::    !r   r   c                \    t          t          | j                            |                    S r   )r   r   r   stemWordr   s     r   r   z_SnowballStemmerAdapter.stem   s"    C//66777r   N)r   r   r   )r   r   r   __doc__r   r   r   r   r   r   r      sB        MM; ; ; ;8 8 8 8 8 8r   r   r   c                     t                      S )z&Return a Snowball stemmer for English.)r   r   r   r   get_english_stemmerr      s    "$$$r   c                  B    e Zd ZdZdd
ZddZedd            ZddZdS )Bm25TokenizerzGTokenizer with stopword filtering and stemming used by BM25 embeddings.r   r   	stopwordsIterable[str]token_max_lengthintr   r   c                    || _         d |D             | _        || _        t          j        dt          j                  | _        d S )Nc                6    h | ]}|                                 S r   )lower).0words     r   	<setcomp>z)Bm25Tokenizer.__init__.<locals>.<setcomp>   s     >>>D4::<<>>>r   z[^\w\s]+)flags)r   
_stopwords_token_max_lengthrj   compileUNICODE_non_alphanumeric_pattern)r   r   r   r   s       r   r   zBm25Tokenizer.__init__   sG      >>I>>>!1)+Krz)R)R)R&&&r   textr   c                8    | j                             d|          S )N )r   sub)r   r   s     r   _remove_non_alphanumericz&Bm25Tokenizer._remove_non_alphanumeric   s    -11#t<<<r   r   c                b    d |                                                                  D             S )Nc                    g | ]}||S r   r   )r   r   s     r   
<listcomp>z2Bm25Tokenizer._simple_tokenize.<locals>.<listcomp>   s    AAA%5AAAAr   )r   split)r   s    r   _simple_tokenizezBm25Tokenizer._simple_tokenize   s*    AA4::<<#5#5#7#7AAAAr   c                4   |                      |          }|                     |          }g }|D ]h}|| j        v rt          |          | j        k    r%| j                            |                                          }|r|                    |           i|S r   )	r   r   r   lenr   r   r   stripappend)r   r   cleaned
raw_tokenstokensr   stemmeds          r   tokenizezBm25Tokenizer.tokenize   s    //55**733
 		' 		'E''5zzD222m((//5577G 'g&&&r   N)r   r   r   r   r   r   r   r   )r   r   r   r   )r   r   r   r   )	r   r   r   r   r   r   staticmethodr   r   r   r   r   r   r      s~        QQ	S 	S 	S 	S= = = = B B B \B     r   r   c                       e Zd ZdddZdd	Zd
S )Murmur3AbsHasherr   seedr   r   r   c                r    	 dd l }n# t          $ r t          d          w xY w|j        | _        || _        d S )Nr   zaThe murmurhash3 python package is not installed. Please install it with `pip install murmurhash3`)mmh3r   r   hashhasherr   )r   r   r   s      r   r   zMurmur3AbsHasher.__init__  sX    	KKKK 	 	 	s  	 i			r   r   r   c           	     z    t          t          t          |                     || j                                      S )N)r   )r   r   absr   r   r   s     r   r   zMurmur3AbsHasher.hash  s,    CT[[TY[??@@AAAr   N)r   )r   r   r   r   )r   r   r   r   )r   r   r   r   r   r   r   r   r   r     sG            B B B B B Br   r   )r   r   r   r   r   r   )r   r   )
__future__r   rj   typingr   r   r   r   r   __annotations__listr   r   r   r   r   r   __all__r   r   r   <module>r      sh   " " " " " " " 				 1 1 1 1 1 1 1 1 1 1 1 1t( t( t(  t t t tn ,040I+J+J  J J J J    h   
8 8 8 8 8 8 8 8"% % % %
% % % % % % % %PB B B B B B B B  r   