Dashboard
PHP:
8.2.30
OS:
Linux
User:
dh_nv8b2m
/
/
usr
/
lib
/
python3
/
dist-packages
/
sphinx
/
util
/
stemmer
/
__pycache__
📤 Upload
📝 New File
📁 New Folder
Close
Editing: porter.cpython-310.pyc
o �$�a�4 � @ s d Z G dd� 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� e Zd Zd'dd�Zdedefdd�Zdefdd �Zdefd d�Zdedefd d�Zdedefdd�Z de defdd�Zde ddfdd�Zde ddfdd�Z d'dd�Zd'dd�Zd'dd�Zd'dd�Zd'd d!�Zd'd"d#�Zd$e dedede fd%d&�ZdS )(� PorterStemmer�returnNc C s d| _ 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__�ic C sz | j | dks#| j | dks#| j | dks#| j | dks#| j | dkr%dS | j | dkr;|| jkr3dS | �|d � S dS ) z(cons(i) is TRUE <=> b[i] is a consonant.�a�er �o�ur �y� )r r �cons�r r r r r r 1 s * zPorterStemmer.consc C s� d}| j } || jkr |S | �|�sn|d }q|d } || jkr%|S | �|�r+n|d }q|d }|d } || jkr@|S | �|�sFn|d }q9|d }q)aF m() 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 .... r r )r r r )r �nr r r r �m= s: � � ��zPorterStemmer.mc C s, t | j| jd �D ] }| �|�s dS q dS )z2vowelinstem() is TRUE <=> k0,...j contains a vowelr r )�ranger r r r r r r �vowelinstemb s �zPorterStemmer.vowelinstemr c C s8 || j d k r dS | j| | j|d krdS | �|�S )z:doublec(j) is TRUE <=> j,(j-1) contain a double consonant.r r )r r r )r r r r r �doubleci s zPorterStemmer.doublecc C sb || j d k s| �|�r| �|d �s| �|d �sdS | j| }|dks-|dks-|dkr/dS dS )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. � r r �w�xr )r r r )r r �chr r r �cvcq s & � zPorterStemmer.cvc�sc C sr t |�}||d | j| j krdS || j| j d krdS | j| j| d | jd � |kr1dS | j| | _dS )z3ends(s) is TRUE <=> k0,...k ends with the string s.r r )�lenr r r r �r r! �lengthr r r �ends� s "zPorterStemmer.endsc C sJ t |�}| jd| jd � | | j| j| d d� | _| j| | _dS )zRsetto(s) sets (j+1),...k to the characters in the string s, readjusting k.Nr )r"