Skip to content

Commit c76d1bd

Browse files
authored
Merge SearchLanguage.init() into __init__() (#13562)
1 parent c4d3705 commit c76d1bd

File tree

18 files changed

+33
-22
lines changed

18 files changed

+33
-22
lines changed

sphinx/search/__init__.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,8 @@ class SearchLanguage:
9191
_word_re = re.compile(r'\w+')
9292

9393
def __init__(self, options: dict[str, str]) -> None:
94-
self.options = options
95-
self.init(options)
96-
97-
def init(self, options: dict[str, str]) -> None:
9894
"""Initialize the class with the options the user has given."""
95+
self.options = options
9996

10097
def split(self, input: str) -> list[str]:
10198
"""This method splits a sentence into words. Default splitter splits input

sphinx/search/da.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ class SearchDanish(SearchLanguage):
111111
js_stemmer_rawcode = 'danish-stemmer.js'
112112
stopwords = danish_stopwords
113113

114-
def init(self, options: dict[str, str]) -> None:
114+
def __init__(self, options: dict[str, str]) -> None:
115+
super().__init__(options)
115116
self.stemmer = snowballstemmer.stemmer('danish')
116117

117118
def stem(self, word: str) -> str:

sphinx/search/de.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,8 @@ class SearchGerman(SearchLanguage):
294294
js_stemmer_rawcode = 'german-stemmer.js'
295295
stopwords = german_stopwords
296296

297-
def init(self, options: dict[str, str]) -> None:
297+
def __init__(self, options: dict[str, str]) -> None:
298+
super().__init__(options)
298299
self.stemmer = snowballstemmer.stemmer('german')
299300

300301
def stem(self, word: str) -> str:

sphinx/search/en.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ class SearchEnglish(SearchLanguage):
211211
js_stemmer_code = js_porter_stemmer
212212
stopwords = english_stopwords
213213

214-
def init(self, options: dict[str, str]) -> None:
214+
def __init__(self, options: dict[str, str]) -> None:
215+
super().__init__(options)
215216
self.stemmer = snowballstemmer.stemmer('porter')
216217

217218
def stem(self, word: str) -> str:

sphinx/search/es.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,8 @@ class SearchSpanish(SearchLanguage):
354354
js_stemmer_rawcode = 'spanish-stemmer.js'
355355
stopwords = spanish_stopwords
356356

357-
def init(self, options: dict[str, str]) -> None:
357+
def __init__(self, options: dict[str, str]) -> None:
358+
super().__init__(options)
358359
self.stemmer = snowballstemmer.stemmer('spanish')
359360

360361
def stem(self, word: str) -> str:

sphinx/search/fi.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ class SearchFinnish(SearchLanguage):
104104
js_stemmer_rawcode = 'finnish-stemmer.js'
105105
stopwords = finnish_stopwords
106106

107-
def init(self, options: dict[str, str]) -> None:
107+
def __init__(self, options: dict[str, str]) -> None:
108+
super().__init__(options)
108109
self.stemmer = snowballstemmer.stemmer('finnish')
109110

110111
def stem(self, word: str) -> str:

sphinx/search/fr.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ class SearchFrench(SearchLanguage):
190190
js_stemmer_rawcode = 'french-stemmer.js'
191191
stopwords = french_stopwords
192192

193-
def init(self, options: dict[str, str]) -> None:
193+
def __init__(self, options: dict[str, str]) -> None:
194+
super().__init__(options)
194195
self.stemmer = snowballstemmer.stemmer('french')
195196

196197
def stem(self, word: str) -> str:

sphinx/search/hu.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ class SearchHungarian(SearchLanguage):
217217
js_stemmer_rawcode = 'hungarian-stemmer.js'
218218
stopwords = hungarian_stopwords
219219

220-
def init(self, options: dict[str, str]) -> None:
220+
def __init__(self, options: dict[str, str]) -> None:
221+
super().__init__(options)
221222
self.stemmer = snowballstemmer.stemmer('hungarian')
222223

223224
def stem(self, word: str) -> str:

sphinx/search/it.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ class SearchItalian(SearchLanguage):
307307
js_stemmer_rawcode = 'italian-stemmer.js'
308308
stopwords = italian_stopwords
309309

310-
def init(self, options: dict[str, str]) -> None:
310+
def __init__(self, options: dict[str, str]) -> None:
311+
super().__init__(options)
311312
self.stemmer = snowballstemmer.stemmer('italian')
312313

313314
def stem(self, word: str) -> str:

sphinx/search/ja.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,8 @@ class SearchJapanese(SearchLanguage):
523523
lang = 'ja'
524524
language_name = 'Japanese'
525525

526-
def init(self, options: dict[str, str]) -> None:
526+
def __init__(self, options: dict[str, str]) -> None:
527+
super().__init__(options)
527528
dotted_path = options.get('type')
528529
if dotted_path is None:
529530
self.splitter = DefaultSplitter(options)

sphinx/search/nl.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ class SearchDutch(SearchLanguage):
118118
js_stemmer_rawcode = 'dutch-stemmer.js'
119119
stopwords = dutch_stopwords
120120

121-
def init(self, options: dict[str, str]) -> None:
121+
def __init__(self, options: dict[str, str]) -> None:
122+
super().__init__(options)
122123
self.stemmer = snowballstemmer.stemmer('dutch')
123124

124125
def stem(self, word: str) -> str:

sphinx/search/no.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ class SearchNorwegian(SearchLanguage):
193193
js_stemmer_rawcode = 'norwegian-stemmer.js'
194194
stopwords = norwegian_stopwords
195195

196-
def init(self, options: dict[str, str]) -> None:
196+
def __init__(self, options: dict[str, str]) -> None:
197+
super().__init__(options)
197198
self.stemmer = snowballstemmer.stemmer('norwegian')
198199

199200
def stem(self, word: str) -> str:

sphinx/search/pt.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ class SearchPortuguese(SearchLanguage):
252252
js_stemmer_rawcode = 'portuguese-stemmer.js'
253253
stopwords = portuguese_stopwords
254254

255-
def init(self, options: dict[str, str]) -> None:
255+
def __init__(self, options: dict[str, str]) -> None:
256+
super().__init__(options)
256257
self.stemmer = snowballstemmer.stemmer('portuguese')
257258

258259
def stem(self, word: str) -> str:

sphinx/search/ro.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ class SearchRomanian(SearchLanguage):
1313
js_stemmer_rawcode = 'romanian-stemmer.js'
1414
stopwords: set[str] = set()
1515

16-
def init(self, options: dict[str, str]) -> None:
16+
def __init__(self, options: dict[str, str]) -> None:
17+
super().__init__(options)
1718
self.stemmer = snowballstemmer.stemmer('romanian')
1819

1920
def stem(self, word: str) -> str:

sphinx/search/ru.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,8 @@ class SearchRussian(SearchLanguage):
242242
js_stemmer_rawcode = 'russian-stemmer.js'
243243
stopwords = russian_stopwords
244244

245-
def init(self, options: dict[str, str]) -> None:
245+
def __init__(self, options: dict[str, str]) -> None:
246+
super().__init__(options)
246247
self.stemmer = snowballstemmer.stemmer('russian')
247248

248249
def stem(self, word: str) -> str:

sphinx/search/sv.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ class SearchSwedish(SearchLanguage):
131131
js_stemmer_rawcode = 'swedish-stemmer.js'
132132
stopwords = swedish_stopwords
133133

134-
def init(self, options: dict[str, str]) -> None:
134+
def __init__(self, options: dict[str, str]) -> None:
135+
super().__init__(options)
135136
self.stemmer = snowballstemmer.stemmer('swedish')
136137

137138
def stem(self, word: str) -> str:

sphinx/search/tr.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ class SearchTurkish(SearchLanguage):
1313
js_stemmer_rawcode = 'turkish-stemmer.js'
1414
stopwords: set[str] = set()
1515

16-
def init(self, options: dict[str, str]) -> None:
16+
def __init__(self, options: dict[str, str]) -> None:
17+
super().__init__(options)
1718
self.stemmer = snowballstemmer.stemmer('turkish')
1819

1920
def stem(self, word: str) -> str:

sphinx/search/zh.py

-2
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,6 @@ class SearchChinese(SearchLanguage):
243243
def __init__(self, options: dict[str, str]) -> None:
244244
super().__init__(options)
245245
self.latin_terms: set[str] = set()
246-
247-
def init(self, options: dict[str, str]) -> None:
248246
dict_path = options.get('dict', JIEBA_DEFAULT_DICT)
249247
if dict_path and Path(dict_path).is_file():
250248
jieba_load_userdict(str(dict_path))

0 commit comments

Comments
 (0)