Skip to content

Commit

Permalink
search zh
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed May 23, 2022
1 parent ba00180 commit 7f257d3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions sphinx/search/zh.py
Expand Up @@ -4,8 +4,9 @@
import re
from typing import Dict, List

import snowballstemmer

from sphinx.search import SearchLanguage
from sphinx.util.stemmer import get_stemmer

try:
import jieba
Expand Down Expand Up @@ -230,7 +231,7 @@ def init(self, options: Dict) -> None:
if dict_path and os.path.isfile(dict_path):
jieba.load_userdict(dict_path)

self.stemmer = get_stemmer()
self.stemmer = snowballstemmer.stemmer('english')

def split(self, input: str) -> List[str]:
chinese: List[str] = []
Expand All @@ -252,8 +253,8 @@ def stem(self, word: str) -> str:
should_not_be_stemmed = (
word in self.latin_terms and
len(word) >= 3 and
len(self.stemmer.stem(word.lower())) < 3
len(self.stemmer.stemWord(word.lower())) < 3
)
if should_not_be_stemmed:
return word.lower()
return self.stemmer.stem(word.lower())
return self.stemmer.stemWord(word.lower())

0 comments on commit 7f257d3

Please sign in to comment.