
    =wg                     d    d dl mZ  G d de      Zd Z	 	 ddZ G d de      Z G d d	e      Zy
)    )	iteritemsc                       e Zd Zy)CompositionErrorN)__name__
__module____qualname__     L/var/www/horilla/myenv/lib/python3.12/site-packages/whoosh/analysis/acore.pyr   r   !   s    r
   r   c                     d | D        S )zCRemoves tokens from a token stream where token.stopped = True.
    c              3   :   K   | ]  }|j                   r|  y wN)stopped).0ts     r   	<genexpr>zunstopped.<locals>.<genexpr>*   s     4!!))A4s   r	   )tokenstreams    r   	unstoppedr   '   s     5{44r
   c              +      K   |}|}t        d||d|}| D ]9  }	|	|_        |r||_        |dz  }|r||_        |t	        |	      z   }||_        | ; yw)aM  Takes a sequence of unicode strings and yields a series of Token objects
    (actually the same Token object over and over, for performance reasons),
    with the attributes filled in with reasonable values (for example, if
    ``positions`` or ``chars`` is True, the function assumes each token was
    separated by one space).
    )	positionschars   Nr	   )Tokentextpos	startcharlenendchar)

textstreamr   r   	start_pos
start_charkwargsr   charr   r   s
             r   entokenr$   -   ss      CD9	9&9A AE1HCAK#d)#DAIs   AAc                   $    e Zd ZdZddZd Zd Zy)r   a  
    Represents a "token" (usually a word) extracted from the source text being
    indexed.

    See "Advanced analysis" in the user guide for more information.

    Because object instantiation in Python is slow, tokenizers should create
    ONE SINGLE Token object and YIELD IT OVER AND OVER, changing the attributes
    each time.

    This trick means that consumers of tokens (i.e. filters) must never try to
    hold onto the token object between loop iterations, or convert the token
    generator into a list. Instead, save the attributes between iterations,
    not the object::

        def RemoveDuplicatesFilter(self, stream):
            # Removes duplicate words.
            lasttext = None
            for token in stream:
                # Only yield the token if its text doesn't
                # match the previous token.
                if lasttext != token.text:
                    yield token
                lasttext = token.text

    ...or, call token.copy() to get a copy of the token object.
    c                     || _         || _        d| _        d| _        || _        || _        | j                  j                  |       y)a  
        :param positions: Whether tokens should have the token position in the
            'pos' attribute.
        :param chars: Whether tokens should have character offsets in the
            'startchar' and 'endchar' attributes.
        :param removestops: whether to remove stop words from the stream (if
            the tokens pass through a stop filter).
        :param mode: contains a string describing the purpose for which the
            analyzer is being called, i.e. 'index' or 'query'.
        Fg      ?N)r   r   r   boostremovestopsmode__dict__update)selfr   r   r(   r)   r"   s         r   __init__zToken.__init__h   sA     #

&	V$r
   c                     dj                  d t        | j                        D              }| j                  j                  d|dS )N, c              3   0   K   | ]  \  }}|d |  yw=Nr	   )r   namevalues      r   r   z!Token.__repr__.<locals>.<genexpr>~   s#      G)dE &*51 G   ())joinr   r*   	__class__r   )r,   parmss     r   __repr__zToken.__repr__}   s>    		 G-6t}}-EG G>>22E::r
   c                 ,    t        di | j                  S )Nr	   )r   r*   r,   s    r   copyz
Token.copy   s    %t}}%%r
   N)FFT )r   r   r   __doc__r-   r;   r>   r	   r
   r   r   r   K   s    8%*;
&r
   r   c                   "    e Zd ZdZd Zd Zd Zy)
ComposableFc                 `    ddl m} t        |t              st	        | d|       || |      S )Nr   )CompositeAnalyzerz is not composable with )whoosh.analysis.analyzersrD   
isinstancerB   	TypeError)r,   otherrD   s      r   __or__zComposable.__or__   s,    ?%,dEJKK u--r
   c                     d}| j                   r+dj                  d t        | j                         D              }| j                  j                  d|z  z   S )Nr?   r/   c              3   0   K   | ]  \  }}|d |  ywr1   r	   )r   keyr4   s      r   r   z&Composable.__repr__.<locals>.<genexpr>   s!      ;",#u *-e4 ;r5   z(%s))r*   r8   r   r9   r   )r,   attrss     r   r;   zComposable.__repr__   sM    ==II ;!*4==!9; ;E ~~&&%77r
   c                     | j                   S r   )is_morphr=   s    r   	has_morphzComposable.has_morph   s    }}r
   N)r   r   r   rO   rI   r;   rP   r	   r
   r   rB   rB      s    H.8r
   rB   N)FFr   r   )	whoosh.compatr   	Exceptionr   r   r$   objectr   rB   r	   r
   r   <module>rT      sC   8 $
	y 	5 AB<9&F 9&| r
   