Fix #2183 porterstemmer causes make json to fail

Drop PorterStemmer package support.
For now, PyStemmer can accelarate stemming process of snowballstemmer.
This commit is contained in:
Takeshi KOMIYA 2015-12-26 11:17:04 +09:00
parent 9c2704b705
commit f1518c5fc4
2 changed files with 6 additions and 16 deletions

View File

@ -21,6 +21,7 @@ Bugs fixed
* #2071: Fix same footnote in more than two section titles => LaTeX/PDF Bug * #2071: Fix same footnote in more than two section titles => LaTeX/PDF Bug
* #2040: Fix UnicodeDecodeError in sphinx-apidoc when author contains non-ascii characters * #2040: Fix UnicodeDecodeError in sphinx-apidoc when author contains non-ascii characters
* #2193: Fix shutil.SameFileError if source directory and destination directory are same * #2193: Fix shutil.SameFileError if source directory and destination directory are same
* #2183: Fix porterstemmer causes `make json` to fail
Release 1.3.3 (released Dec 2, 2015) Release 1.3.3 (released Dec 2, 2015)

View File

@ -12,18 +12,11 @@
from sphinx.search import SearchLanguage from sphinx.search import SearchLanguage
try: try:
# http://bitbucket.org/methane/porterstemmer/ from Stemmer import Stemmer as PyStemmer
from porterstemmer import Stemmer as CStemmer PYSTEMMER = True
CSTEMMER = True
PYSTEMMER = False
except ImportError: except ImportError:
CSTEMMER = False from sphinx.util.stemmer import PorterStemmer
try: PYSTEMMER = False
from Stemmer import Stemmer as PyStemmer
PYSTEMMER = True
except ImportError:
from sphinx.util.stemmer import PorterStemmer
PYSTEMMER = False
english_stopwords = set(""" english_stopwords = set("""
a and are as at a and are as at
@ -231,11 +224,7 @@ class SearchEnglish(SearchLanguage):
stopwords = english_stopwords stopwords = english_stopwords
def init(self, options): def init(self, options):
if CSTEMMER: if PYSTEMMER:
class Stemmer(CStemmer):
def stem(self, word):
return self(word.lower())
elif PYSTEMMER:
class Stemmer(object): class Stemmer(object):
def __init__(self): def __init__(self):
self.stemmer = PyStemmer('porter') self.stemmer = PyStemmer('porter')