1""" 2 sphinx.search.ru 3 ~~~~~~~~~~~~~~~~ 4 5 Russian search language: includes the JS Russian stemmer. 6 7 :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS. 8 :license: BSD, see LICENSE for details. 9""" 10 11from typing import Dict 12 13import snowballstemmer 14 15from sphinx.search import SearchLanguage, parse_stop_word 16 17russian_stopwords = parse_stop_word(''' 18| source: http://snowball.tartarus.org/algorithms/russian/stop.txt 19и | and 20в | in/into 21во | alternative form 22не | not 23что | what/that 24он | he 25на | on/onto 26я | i 27с | from 28со | alternative form 29как | how 30а | milder form of `no' (but) 31то | conjunction and form of `that' 32все | all 33она | she 34так | so, thus 35его | him 36но | but 37да | yes/and 38ты | thou 39к | towards, by 40у | around, chez 41же | intensifier particle 42вы | you 43за | beyond, behind 44бы | conditional/subj. particle 45по | up to, along 46только | only 47ее | her 48мне | to me 49было | it was 50вот | here is/are, particle 51от | away from 52меня | me 53еще | still, yet, more 54нет | no, there isnt/arent 55о | about 56из | out of 57ему | to him 58теперь | now 59когда | when 60даже | even 61ну | so, well 62вдруг | suddenly 63ли | interrogative particle 64если | if 65уже | already, but homonym of `narrower' 66или | or 67ни | neither 68быть | to be 69был | he was 70него | prepositional form of его 71до | up to 72вас | you accusative 73нибудь | indef. suffix preceded by hyphen 74опять | again 75уж | already, but homonym of `adder' 76вам | to you 77сказал | he said 78ведь | particle `after all' 79там | there 80потом | then 81себя | oneself 82ничего | nothing 83ей | to her 84может | usually with `быть' as `maybe' 85они | they 86тут | here 87где | where 88есть | there is/are 89надо | got to, must 90ней | prepositional form of ей 91для | for 92мы | we 93тебя | thee 94их | them, their 95чем | than 96была | she was 97сам | self 98чтоб | in order to 99без | without 100будто | as if 101человек | man, person, one 102чего | genitive form of `what' 103раз | once 104тоже | also 105себе | to oneself 106под | beneath 107жизнь | life 108будет | will be 109ж | short form of intensifer particle `же' 110тогда | then 111кто | who 112этот | this 113говорил | was saying 114того | genitive form of `that' 115потому | for that reason 116этого | genitive form of `this' 117какой | which 118совсем | altogether 119ним | prepositional form of `его', `они' 120здесь | here 121этом | prepositional form of `этот' 122один | one 123почти | almost 124мой | my 125тем | instrumental/dative plural of `тот', `то' 126чтобы | full form of `in order that' 127нее | her (acc.) 128кажется | it seems 129сейчас | now 130были | they were 131куда | where to 132зачем | why 133сказать | to say 134всех | all (acc., gen. preposn. plural) 135никогда | never 136сегодня | today 137можно | possible, one can 138при | by 139наконец | finally 140два | two 141об | alternative form of `о', about 142другой | another 143хоть | even 144после | after 145над | above 146больше | more 147тот | that one (masc.) 148через | across, in 149эти | these 150нас | us 151про | about 152всего | in all, only, of all 153них | prepositional form of `они' (they) 154какая | which, feminine 155много | lots 156разве | interrogative particle 157сказала | she said 158три | three 159эту | this, acc. fem. sing. 160моя | my, feminine 161впрочем | moreover, besides 162хорошо | good 163свою | ones own, acc. fem. sing. 164этой | oblique form of `эта', fem. `this' 165перед | in front of 166иногда | sometimes 167лучше | better 168чуть | a little 169том | preposn. form of `that one' 170нельзя | one must not 171такой | such a one 172им | to them 173более | more 174всегда | always 175конечно | of course 176всю | acc. fem. sing of `all' 177между | between 178 179 180 | b: some paradigms 181 | 182 | personal pronouns 183 | 184 | я меня мне мной [мною] 185 | ты тебя тебе тобой [тобою] 186 | он его ему им [него, нему, ним] 187 | она ее эи ею [нее, нэи, нею] 188 | оно его ему им [него, нему, ним] 189 | 190 | мы нас нам нами 191 | вы вас вам вами 192 | они их им ими [них, ним, ними] 193 | 194 | себя себе собой [собою] 195 | 196 | demonstrative pronouns: этот (this), тот (that) 197 | 198 | этот эта это эти 199 | этого эты это эти 200 | этого этой этого этих 201 | этому этой этому этим 202 | этим этой этим [этою] этими 203 | этом этой этом этих 204 | 205 | тот та то те 206 | того ту то те 207 | того той того тех 208 | тому той тому тем 209 | тем той тем [тою] теми 210 | том той том тех 211 | 212 | determinative pronouns 213 | 214 | (a) весь (all) 215 | 216 | весь вся все все 217 | всего всю все все 218 | всего всей всего всех 219 | всему всей всему всем 220 | всем всей всем [всею] всеми 221 | всем всей всем всех 222 | 223 | (b) сам (himself etc) 224 | 225 | сам сама само сами 226 | самого саму само самих 227 | самого самой самого самих 228 | самому самой самому самим 229 | самим самой самим [самою] самими 230 | самом самой самом самих 231 | 232 | stems of verbs `to be', `to have', `to do' and modal 233 | 234 | быть бы буд быв есть суть 235 | име 236 | дел 237 | мог мож мочь 238 | уме 239 | хоч хот 240 | долж 241 | можн 242 | нужн 243 | нельзя 244''') 245 246 247class SearchRussian(SearchLanguage): 248 lang = 'ru' 249 language_name = 'Russian' 250 js_stemmer_rawcode = 'russian-stemmer.js' 251 stopwords = russian_stopwords 252 253 def init(self, options: Dict) -> None: 254 self.stemmer = snowballstemmer.stemmer('russian') 255 256 def stem(self, word: str) -> str: 257 return self.stemmer.stemWord(word.lower()) 258