/usr/lib/python2.7/dist-packages/sphinx/util/stemmer/__init__.py is in python-sphinx 1.6.7-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | # -*- coding: utf-8 -*-
"""
sphinx.util.stemmer
~~~~~~~~~~~~~~~~~~~
Word stemming utilities for Sphinx.
:copyright: Copyright 2007-2018 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(object):
def stem(self, word):
# type: (unicode) -> unicode
raise NotImplemented
class PyStemmer(BaseStemmer):
def __init__(self):
# type: () -> None
self.stemmer = _PyStemmer('porter')
def stem(self, word):
# type: (unicode) -> unicode
return self.stemmer.stemWord(word)
class StandardStemmer(BaseStemmer, PorterStemmer): # type: ignore
"""All those porter stemmer implementations look hideous;
make at least the stem method nicer.
"""
def stem(self, word): # type: ignore
# type: (unicode) -> unicode
return PorterStemmer.stem(self, word, 0, len(word) - 1)
def get_stemmer():
# type: () -> BaseStemmer
if PYSTEMMER:
return PyStemmer()
else:
return StandardStemmer()
|