https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/sphinx/util/stemmer/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/sphinx/util/stemmer/__init__.py
"""
    sphinx.util.stemmer
    ~~~~~~~~~~~~~~~~~~~

    Word stemming utilities for Sphinx.

    :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
"""

from sphinx.util.stemmer.porter import PorterStemmer

try:
    from Stemmer import Stemmer as _PyStemmer
    PYSTEMMER = True
except ImportError:
    PYSTEMMER = False


class BaseStemmer:
    def stem(self, word: str) -> str:
        raise NotImplementedError()


class PyStemmer(BaseStemmer):
    def __init__(self) -> None:
        self.stemmer = _PyStemmer('porter')

    def stem(self, word: str) -> str:
        return self.stemmer.stemWord(word)


class StandardStemmer(PorterStemmer, BaseStemmer):
    """All those porter stemmer implementations look hideous;
    make at least the stem method nicer.
    """
    def stem(self, word: str) -> str:  # type: ignore
        return super().stem(word, 0, len(word) - 1)


def get_stemmer() -> BaseStemmer:
    if PYSTEMMER:
        return PyStemmer()
    else:
        return StandardStemmer()

https://t.me/RX1948 - 2025