mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Migrate to py3 style type annotation: sphinx.util.stemmer
This commit is contained in:
parent
1659cc264c
commit
ffe5e129c3
@ -18,18 +18,15 @@ except ImportError:
|
||||
|
||||
|
||||
class BaseStemmer:
|
||||
def stem(self, word):
|
||||
# type: (str) -> str
|
||||
def stem(self, word: str) -> str:
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
class PyStemmer(BaseStemmer):
|
||||
def __init__(self):
|
||||
# type: () -> None
|
||||
def __init__(self) -> None:
|
||||
self.stemmer = _PyStemmer('porter')
|
||||
|
||||
def stem(self, word):
|
||||
# type: (str) -> str
|
||||
def stem(self, word: str) -> str:
|
||||
return self.stemmer.stemWord(word)
|
||||
|
||||
|
||||
@ -37,13 +34,11 @@ class StandardStemmer(PorterStemmer, BaseStemmer): # type: ignore
|
||||
"""All those porter stemmer implementations look hideous;
|
||||
make at least the stem method nicer.
|
||||
"""
|
||||
def stem(self, word): # type: ignore
|
||||
# type: (str) -> str
|
||||
def stem(self, word: str) -> str: # type: ignore
|
||||
return super().stem(word, 0, len(word) - 1)
|
||||
|
||||
|
||||
def get_stemmer():
|
||||
# type: () -> BaseStemmer
|
||||
def get_stemmer() -> BaseStemmer:
|
||||
if PYSTEMMER:
|
||||
return PyStemmer()
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user