HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/sphinx/util/stemmer/__pycache__/porter.cpython-310.pyc
o

�$�a�4�@sdZGdd�d�ZdS)a

    sphinx.util.stemmer.porter
    ~~~~~~~~~~~~~~~~~~~~~~~~~~

    Porter Stemming Algorithm

    This is the Porter stemming algorithm, ported to Python from the
    version coded up in ANSI C by the author. It may be be regarded
    as canonical, in that it follows the algorithm presented in

    Porter, 1980, An algorithm for suffix stripping, Program, Vol. 14,
    no. 3, pp 130-137,

    only differing from it at the points made --DEPARTURE-- below.

    See also https://tartarus.org/martin/PorterStemmer/

    The algorithm as described in the paper could be exactly replicated
    by adjusting the points of DEPARTURE, but this is barely necessary,
    because (a) the points of DEPARTURE are definitely improvements, and
    (b) no encoding of the Porter stemmer I have seen is anything like
    as exact as this version, even with the points of DEPARTURE!

    Release 1: January 2001

    :copyright: Copyright 2001 by Vivake Gupta <v@nano.com>.
    :license: Public Domain ("can be used free of charge for any purpose").
c@s�eZdZd'dd�Zdedefdd�Zdefdd	�Zdefd
d�Zdedefd
d�Zdedefdd�Z	de
defdd�Zde
ddfdd�Zde
ddfdd�Z
d'dd�Zd'dd�Zd'dd�Zd'dd�Zd'd d!�Zd'd"d#�Zd$e
dedede
fd%d&�ZdS)(�
PorterStemmer�returnNcCsd|_d|_d|_d|_dS)a�The main part of the stemming algorithm starts here.
        b is a buffer holding a word to be stemmed. The letters are in b[k0],
        b[k0+1] ... ending at b[k]. In fact k0 = 0 in this demo program. k is
        readjusted downwards as the stemming progresses. Zero termination is
        not in fact used in the algorithm.

        Note that only lower case sequences are stemmed. Forcing to lower case
        should be done before stem(...) is called.
        ��N)�b�k�k0�j��self�r�</usr/lib/python3/dist-packages/sphinx/util/stemmer/porter.py�__init__!s
zPorterStemmer.__init__�icCsz|j|dks#|j|dks#|j|dks#|j|dks#|j|dkr%dS|j|dkr;||jkr3dS|�|d�SdS)	z(cons(i) is TRUE <=> b[i] is a consonant.�a�er�o�ur�y�)rr�cons�r
rrrrr1s*
zPorterStemmer.conscCs�d}|j}	||jkr
|S|�|�sn|d}q|d}		||jkr%|S|�|�r+n|d}q|d}|d}	||jkr@|S|�|�sFn|d}q9|d}q)aFm() measures the number of consonant sequences between k0 and j.
        if c is a consonant sequence and v a vowel sequence, and <..>
        indicates arbitrary presence,

           <c><v>       gives 0
           <c>vc<v>     gives 1
           <c>vcvc<v>   gives 2
           <c>vcvcvc<v> gives 3
           ....
        rr)rrr)r
�nrrrr�m=s:

�

�

��zPorterStemmer.mcCs,t|j|jd�D]
}|�|�sdSq	dS)z2vowelinstem() is TRUE <=> k0,...j contains a vowelrr)�rangerrrrrrr�vowelinstembs

�zPorterStemmer.vowelinstemrcCs8||jdkr	dS|j||j|dkrdS|�|�S)z:doublec(j) is TRUE <=> j,(j-1) contain a double consonant.rr)rrr)r
rrrr�doublecis

zPorterStemmer.doubleccCsb||jdks|�|�r|�|d�s|�|d�sdS|j|}|dks-|dks-|dkr/dSdS)a)cvc(i) is TRUE <=> i-2,i-1,i has the form
             consonant - vowel - consonant
        and also if the second c is not w,x or y. this is used when trying to
        restore an e at the end of a short  e.g.

           cav(e), lov(e), hop(e), crim(e), but
           snow, box, tray.
        �rr�w�xr)rrr)r
r�chrrr�cvcqs&	�
zPorterStemmer.cvc�scCsrt|�}||d|j|jkrdS||j|jdkrdS|j|j|d|jd�|kr1dS|j||_dS)z3ends(s) is TRUE <=> k0,...k ends with the string s.rr)�lenrrrr�r
r!�lengthrrr�ends�s"zPorterStemmer.endscCsJt|�}|jd|jd�||j|j|dd�|_|j||_dS)zRsetto(s) sets (j+1),...k to the characters in the string s,
        readjusting k.Nr)r"rrrr#rrr�setto�s2zPorterStemmer.settocCs|��dkr
|�|�dSdS)zr(s) is used further down.rN)rr&)r
r!rrr�r�s�zPorterStemmer.rcCsz|j|jdkr/|�d�r|jd|_n|�d�r|�d�n|j|jddkr/|jd|_|�d�rD|��dkrB|jd|_dSdS|�d	�sN|�d
�r�|��r�|j|_|�d�rb|�d�dS|�d
�rn|�d�dS|�d�rz|�d�dS|�|j�r�|jd|_|j|j}|dks�|dks�|dkr�|jd|_dSdS|��dkr�|�|j�r�|�d�dSdSdSdSdS)a�step1ab() gets rid of plurals and -ed or -ing. e.g.

           caresses  ->  caress
           ponies    ->  poni
           ties      ->  ti
           caress    ->  caress
           cats      ->  cat

           feed      ->  feed
           agreed    ->  agree
           disabled  ->  disable

           matting   ->  mat
           mating    ->  mate
           meeting   ->  meet
           milling   ->  mill
           messing   ->  mess

           meetings  ->  meet
        r!�ssesr�iesrr�eedr�ed�ing�at�ate�bl�ble�iz�ize�l�zrN)	rrr%r&rrrrr )r
rrrr�step1ab�s:


�


��
zPorterStemmer.step1abcCsH|�d�r |��r"|jd|j�d|j|jdd�|_dSdSdS)zOstep1c() turns terminal y to i when there is another vowel in
        the stem.rNrr)r%rrrr	rrr�step1c�s.�zPorterStemmer.step1ccCs�|j|jddkr$|�d�r|�d�d+S|�d�r"|�d�d+Sd+S|j|jddkrH|�d�r:|�d	�d+S|�d
�rF|�d�d+Sd+S|j|jddkr`|�d
�r^|�d�d+Sd+S|j|jddkr�|�d�rv|�d�d+S|�d�r�|�d�d+S|�d�r�|�d�d+S|�d�r�|�d�d+S|�d�r�|�d�d+Sd+S|j|jddkr�|�d�r�|�d�d+S|�d�r�|�d�d+S|�d�r�|�d�d+Sd+S|j|jddk�r|�d�r�|�d�d+S|�d�r�|�d �d+S|�d!��r|�d"�d+S|�d#��r|�d�d+Sd+S|j|jdd$k�rK|�d%��r/|�d�d+S|�d&��r<|�d �d+S|�d'��rI|�d�d+Sd+S|j|jdd(k�rc|�d)��re|�d*�d+Sd+Sd+S),z�step2() maps double suffices to single ones.
        so -ization ( = -ize plus -ation) maps to -ize etc. note that the
        string before the suffix must give m() > 0.
        rr�ationalr.�tional�tion�c�enci�ence�anci�ancer�izerr2r3�blir0�alli�al�entli�ent�eli�ousli�ousr�ization�ation�atorr!�alism�iveness�ive�fulness�ful�ousness�t�aliti�iviti�biliti�g�logi�logN�rrr%r'r	rrr�step2�sv

�

�
�




�


�

���zPorterStemmer.step2cCs�|j|jdkr.|�d�r|�d�dS|�d�r |�d�dS|�d�r,|�d�dSdS|j|jdkrD|�d	�rB|�d�dSdS|j|jd
krf|�d�rX|�d�dS|�d�rd|�d�dSdS|j|jd
krz|�d�r||�d�dSdSdS)zLstep3() dels with -ic-, -full, -ness etc. similar strategy
        to step2.r�icate�ic�ativer�alizerBr�icitir3�icalrOr!�nessNrXr	rrr�step3
s.


�
�

�
�zPorterStemmer.step3cCsP|j|jddkr|�d�r�ndS|j|jddkr+|�d�r#n�|�d�r)n�dS|j|jddkr=|�d	�r;n�dS|j|jdd
krO|�d�rMn�dS|j|jddkrg|�d
�r_n�|�d�ren�dS|j|jddkr�|�d�rwn�|�d�r}n�|�d�r�n�|�d�r�n�dS|j|jddkr�|�d�r�|j|jdks�|j|jdkr�nn|�d�r�nhdS|j|jddkr�|�d�r�nVdS|j|jddkr�|�d�r�nD|�d�r�n>dS|j|jddkr�|�d�r�n,dS|j|jddk�r|�d��rndS|j|jdd k�r|�d!��rndSdS|��dk�r&|j|_dSdS)"z:step4() takes off -ant, -ence etc., in context <c>vcvc<v>.rrrBNr:r>r<r�errr[r3�able�ibler�ant�ement�mentrDr�ionr!rQ�ou�ismr.�itirrG�vrMr4r2)rrr%rrr	rrr�step4 s�















�zPorterStemmer.step4cCs�|j|_|j|jdkr&|��}|dks |dkr&|�|jd�s&|jd|_|j|jdkrB|�|j�rD|��dkrF|jd|_dSdSdSdS)zYstep5() removes a final -e if m() > 1, and changes -ll to -l if
        m() > 1.
        rrr3N)rrrrr r)r
rrrr�step5ss (�zPorterStemmer.step5�pcCsn||_||_||_|j|jdkr|jS|��|��|��|��|��|��|j|j|jd�S)a�In stem(p,i,j), p is a char pointer, and the string to be stemmed
        is from p[i] to p[j] inclusive. Typically i is zero and j is the
        offset to the last character of a string, (p[j+1] == ''). The
        stemmer adjusts the characters p[i] ... p[j] and returns the new
        end-point of the string, k. Stemming never increases word length, so
        i <= k <= j. To turn the stemmer into a module, declare 'stem' as
        extern, and delete the remainder of this file.
        r)	rrrr5r6rYrarmrn)r
rorrrrr�stems
zPorterStemmer.stem)rN)�__name__�
__module__�__qualname__r
�intrrrrr �strr%r&r'r5r6rYrarmrnrprrrrrs"
%

/

;

SrN)�__doc__rrrrr�<module>s