1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
# Generated by Snowball 2.2.0 - https://snowballstem.org/

from .basestemmer import BaseStemmer
from .among import Among


class RussianStemmer(BaseStemmer):
    '''
    This class implements the stemming algorithm defined by a snowball script.
    Generated by Snowball 2.2.0 - https://snowballstem.org/
    '''

    a_0 = [
        Among(u"\u0432", -1, 1),
        Among(u"\u0438\u0432", 0, 2),
        Among(u"\u044B\u0432", 0, 2),
        Among(u"\u0432\u0448\u0438", -1, 1),
        Among(u"\u0438\u0432\u0448\u0438", 3, 2),
        Among(u"\u044B\u0432\u0448\u0438", 3, 2),
        Among(u"\u0432\u0448\u0438\u0441\u044C", -1, 1),
        Among(u"\u0438\u0432\u0448\u0438\u0441\u044C", 6, 2),
        Among(u"\u044B\u0432\u0448\u0438\u0441\u044C", 6, 2)
    ]

    a_1 = [
        Among(u"\u0435\u0435", -1, 1),
        Among(u"\u0438\u0435", -1, 1),
        Among(u"\u043E\u0435", -1, 1),
        Among(u"\u044B\u0435", -1, 1),
        Among(u"\u0438\u043C\u0438", -1, 1),
        Among(u"\u044B\u043C\u0438", -1, 1),
        Among(u"\u0435\u0439", -1, 1),
        Among(u"\u0438\u0439", -1, 1),
        Among(u"\u043E\u0439", -1, 1),
        Among(u"\u044B\u0439", -1, 1),
        Among(u"\u0435\u043C", -1, 1),
        Among(u"\u0438\u043C", -1, 1),
        Among(u"\u043E\u043C", -1, 1),
        Among(u"\u044B\u043C", -1, 1),
        Among(u"\u0435\u0433\u043E", -1, 1),
        Among(u"\u043E\u0433\u043E", -1, 1),
        Among(u"\u0435\u043C\u0443", -1, 1),
        Among(u"\u043E\u043C\u0443", -1, 1),
        Among(u"\u0438\u0445", -1, 1),
        Among(u"\u044B\u0445", -1, 1),
        Among(u"\u0435\u044E", -1, 1),
        Among(u"\u043E\u044E", -1, 1),
        Among(u"\u0443\u044E", -1, 1),
        Among(u"\u044E\u044E", -1, 1),
        Among(u"\u0430\u044F", -1, 1),
        Among(u"\u044F\u044F", -1, 1)
    ]

    a_2 = [
        Among(u"\u0435\u043C", -1, 1),
        Among(u"\u043D\u043D", -1, 1),
        Among(u"\u0432\u0448", -1, 1),
        Among(u"\u0438\u0432\u0448", 2, 2),
        Among(u"\u044B\u0432\u0448", 2, 2),
        Among(u"\u0449", -1, 1),
        Among(u"\u044E\u0449", 5, 1),
        Among(u"\u0443\u044E\u0449", 6, 2)
    ]

    a_3 = [
        Among(u"\u0441\u044C", -1, 1),
        Among(u"\u0441\u044F", -1, 1)
    ]

    a_4 = [
        Among(u"\u043B\u0430", -1, 1),
        Among(u"\u0438\u043B\u0430", 0, 2),
        Among(u"\u044B\u043B\u0430", 0, 2),
        Among(u"\u043D\u0430", -1, 1),
        Among(u"\u0435\u043D\u0430", 3, 2),
        Among(u"\u0435\u0442\u0435", -1, 1),
        Among(u"\u0438\u0442\u0435", -1, 2),
        Among(u"\u0439\u0442\u0435", -1, 1),
        Among(u"\u0435\u0439\u0442\u0435", 7, 2),
        Among(u"\u0443\u0439\u0442\u0435", 7, 2),
        Among(u"\u043B\u0438", -1, 1),
        Among(u"\u0438\u043B\u0438", 10, 2),
        Among(u"\u044B\u043B\u0438", 10, 2),
        Among(u"\u0439", -1, 1),
        Among(u"\u0435\u0439", 13, 2),
        Among(u"\u0443\u0439", 13, 2),
        Among(u"\u043B", -1, 1),
        Among(u"\u0438\u043B", 16, 2),
        Among(u"\u044B\u043B", 16, 2),
        Among(u"\u0435\u043C", -1, 1),
        Among(u"\u0438\u043C", -1, 2),
        Among(u"\u044B\u043C", -1, 2),
        Among(u"\u043D", -1, 1),
        Among(u"\u0435\u043D", 22, 2),
        Among(u"\u043B\u043E", -1, 1),
        Among(u"\u0438\u043B\u043E", 24, 2),
        Among(u"\u044B\u043B\u043E", 24, 2),
        Among(u"\u043D\u043E", -1, 1),
        Among(u"\u0435\u043D\u043E", 27, 2),
        Among(u"\u043D\u043D\u043E", 27, 1),
        Among(u"\u0435\u0442", -1, 1),
        Among(u"\u0443\u0435\u0442", 30, 2),
        Among(u"\u0438\u0442", -1, 2),
        Among(u"\u044B\u0442", -1, 2),
        Among(u"\u044E\u0442", -1, 1),
        Among(u"\u0443\u044E\u0442", 34, 2),
        Among(u"\u044F\u0442", -1, 2),
        Among(u"\u043D\u044B", -1, 1),
        Among(u"\u0435\u043D\u044B", 37, 2),
        Among(u"\u0442\u044C", -1, 1),
        Among(u"\u0438\u0442\u044C", 39, 2),
        Among(u"\u044B\u0442\u044C", 39, 2),
        Among(u"\u0435\u0448\u044C", -1, 1),
        Among(u"\u0438\u0448\u044C", -1, 2),
        Among(u"\u044E", -1, 2),
        Among(u"\u0443\u044E", 44, 2)
    ]

    a_5 = [
        Among(u"\u0430", -1, 1),
        Among(u"\u0435\u0432", -1, 1),
        Among(u"\u043E\u0432", -1, 1),
        Among(u"\u0435", -1, 1),
        Among(u"\u0438\u0435", 3, 1),
        Among(u"\u044C\u0435", 3, 1),
        Among(u"\u0438", -1, 1),
        Among(u"\u0435\u0438", 6, 1),
        Among(u"\u0438\u0438", 6, 1),
        Among(u"\u0430\u043C\u0438", 6, 1),
        Among(u"\u044F\u043C\u0438", 6, 1),
        Among(u"\u0438\u044F\u043C\u0438", 10, 1),
        Among(u"\u0439", -1, 1),
        Among(u"\u0435\u0439", 12, 1),
        Among(u"\u0438\u0435\u0439", 13, 1),
        Among(u"\u0438\u0439", 12, 1),
        Among(u"\u043E\u0439", 12, 1),
        Among(u"\u0430\u043C", -1, 1),
        Among(u"\u0435\u043C", -1, 1),
        Among(u"\u0438\u0435\u043C", 18, 1),
        Among(u"\u043E\u043C", -1, 1),
        Among(u"\u044F\u043C", -1, 1),
        Among(u"\u0438\u044F\u043C", 21, 1),
        Among(u"\u043E", -1, 1),
        Among(u"\u0443", -1, 1),
        Among(u"\u0430\u0445", -1, 1),
        Among(u"\u044F\u0445", -1, 1),
        Among(u"\u0438\u044F\u0445", 26, 1),
        Among(u"\u044B", -1, 1),
        Among(u"\u044C", -1, 1),
        Among(u"\u044E", -1, 1),
        Among(u"\u0438\u044E", 30, 1),
        Among(u"\u044C\u044E", 30, 1),
        Among(u"\u044F", -1, 1),
        Among(u"\u0438\u044F", 33, 1),
        Among(u"\u044C\u044F", 33, 1)
    ]

    a_6 = [
        Among(u"\u043E\u0441\u0442", -1, 1),
        Among(u"\u043E\u0441\u0442\u044C", -1, 1)
    ]

    a_7 = [
        Among(u"\u0435\u0439\u0448\u0435", -1, 1),
        Among(u"\u043D", -1, 2),
        Among(u"\u0435\u0439\u0448", -1, 1),
        Among(u"\u044C", -1, 3)
    ]

    g_v = [33, 65, 8, 232]

    I_p2 = 0
    I_pV = 0

    def __r_mark_regions(self):
        self.I_pV = self.limit
        self.I_p2 = self.limit
        v_1 = self.cursor
        try:
            if not self.go_out_grouping(RussianStemmer.g_v, 1072, 1103):
                raise lab0()
            self.cursor += 1
            self.I_pV = self.cursor
            if not self.go_in_grouping(RussianStemmer.g_v, 1072, 1103):
                raise lab0()
            self.cursor += 1
            if not self.go_out_grouping(RussianStemmer.g_v, 1072, 1103):
                raise lab0()
            self.cursor += 1
            if not self.go_in_grouping(RussianStemmer.g_v, 1072, 1103):
                raise lab0()
            self.cursor += 1
            self.I_p2 = self.cursor
        except lab0: pass
        self.cursor = v_1
        return True

    def __r_R2(self):
        if not self.I_p2 <= self.cursor:
            return False
        return True

    def __r_perfective_gerund(self):
        self.ket = self.cursor
        among_var = self.find_among_b(RussianStemmer.a_0)
        if among_var == 0:
            return False
        self.bra = self.cursor
        if among_var == 1:
            try:
                v_1 = self.limit - self.cursor
                try:
                    if not self.eq_s_b(u"\u0430"):
                        raise lab1()
                    raise lab0()
                except lab1: pass
                self.cursor = self.limit - v_1
                if not self.eq_s_b(u"\u044F"):
                    return False
            except lab0: pass
            if not self.slice_del():
                return False

        else:
            if not self.slice_del():
                return False

        return True

    def __r_adjective(self):
        self.ket = self.cursor
        if self.find_among_b(RussianStemmer.a_1) == 0:
            return False
        self.bra = self.cursor
        if not self.slice_del():
            return False

        return True

    def __r_adjectival(self):
        if not self.__r_adjective():
            return False
        v_1 = self.limit - self.cursor
        try:
            self.ket = self.cursor
            among_var = self.find_among_b(RussianStemmer.a_2)
            if among_var == 0:
                self.cursor = self.limit - v_1
                raise lab0()
            self.bra = self.cursor
            if among_var == 1:
                try:
                    v_2 = self.limit - self.cursor
                    try:
                        if not self.eq_s_b(u"\u0430"):
                            raise lab2()
                        raise lab1()
                    except lab2: pass
                    self.cursor = self.limit - v_2
                    if not self.eq_s_b(u"\u044F"):
                        self.cursor = self.limit - v_1
                        raise lab0()
                except lab1: pass
                if not self.slice_del():
                    return False

            else:
                if not self.slice_del():
                    return False

        except lab0: pass
        return True

    def __r_reflexive(self):
        self.ket = self.cursor
        if self.find_among_b(RussianStemmer.a_3) == 0:
            return False
        self.bra = self.cursor
        if not self.slice_del():
            return False

        return True

    def __r_verb(self):
        self.ket = self.cursor
        among_var = self.find_among_b(RussianStemmer.a_4)
        if among_var == 0:
            return False
        self.bra = self.cursor
        if among_var == 1:
            try:
                v_1 = self.limit - self.cursor
                try:
                    if not self.eq_s_b(u"\u0430"):
                        raise lab1()
                    raise lab0()
                except lab1: pass
                self.cursor = self.limit - v_1
                if not self.eq_s_b(u"\u044F"):
                    return False
            except lab0: pass
            if not self.slice_del():
                return False

        else:
            if not self.slice_del():
                return False

        return True

    def __r_noun(self):
        self.ket = self.cursor
        if self.find_among_b(RussianStemmer.a_5) == 0:
            return False
        self.bra = self.cursor
        if not self.slice_del():
            return False

        return True

    def __r_derivational(self):
        self.ket = self.cursor
        if self.find_among_b(RussianStemmer.a_6) == 0:
            return False
        self.bra = self.cursor
        if not self.__r_R2():
            return False
        if not self.slice_del():
            return False

        return True

    def __r_tidy_up(self):
        self.ket = self.cursor
        among_var = self.find_among_b(RussianStemmer.a_7)
        if among_var == 0:
            return False
        self.bra = self.cursor
        if among_var == 1:
            if not self.slice_del():
                return False

            self.ket = self.cursor
            if not self.eq_s_b(u"\u043D"):
                return False
            self.bra = self.cursor
            if not self.eq_s_b(u"\u043D"):
                return False
            if not self.slice_del():
                return False

        elif among_var == 2:
            if not self.eq_s_b(u"\u043D"):
                return False
            if not self.slice_del():
                return False

        else:
            if not self.slice_del():
                return False

        return True

    def _stem(self):
        v_1 = self.cursor
        try:
            while True:
                v_2 = self.cursor
                try:
                    try:
                        while True:
                            v_3 = self.cursor
                            try:
                                self.bra = self.cursor
                                if not self.eq_s(u"\u0451"):
                                    raise lab3()
                                self.ket = self.cursor
                                self.cursor = v_3
                                raise lab2()
                            except lab3: pass
                            self.cursor = v_3
                            if self.cursor >= self.limit:
                                raise lab1()
                            self.cursor += 1
                    except lab2: pass
                    if not self.slice_from(u"\u0435"):
                        return False
                    continue
                except lab1: pass
                self.cursor = v_2
                break
        except lab0: pass
        self.cursor = v_1
        self.__r_mark_regions()
        self.limit_backward = self.cursor
        self.cursor = self.limit
        if self.cursor < self.I_pV:
            return False
        v_6 = self.limit_backward
        self.limit_backward = self.I_pV
        v_7 = self.limit - self.cursor
        try:
            try:
                v_8 = self.limit - self.cursor
                try:
                    if not self.__r_perfective_gerund():
                        raise lab6()
                    raise lab5()
                except lab6: pass
                self.cursor = self.limit - v_8
                v_9 = self.limit - self.cursor
                try:
                    if not self.__r_reflexive():
                        self.cursor = self.limit - v_9
                        raise lab7()
                except lab7: pass
                try:
                    v_10 = self.limit - self.cursor
                    try:
                        if not self.__r_adjectival():
                            raise lab9()
                        raise lab8()
                    except lab9: pass
                    self.cursor = self.limit - v_10
                    try:
                        if not self.__r_verb():
                            raise lab10()
                        raise lab8()
                    except lab10: pass
                    self.cursor = self.limit - v_10
                    if not self.__r_noun():
                        raise lab4()
                except lab8: pass
            except lab5: pass
        except lab4: pass
        self.cursor = self.limit - v_7
        v_11 = self.limit - self.cursor
        try:
            self.ket = self.cursor
            if not self.eq_s_b(u"\u0438"):
                self.cursor = self.limit - v_11
                raise lab11()
            self.bra = self.cursor
            if not self.slice_del():
                return False

        except lab11: pass
        v_12 = self.limit - self.cursor
        self.__r_derivational()
        self.cursor = self.limit - v_12
        v_13 = self.limit - self.cursor
        self.__r_tidy_up()
        self.cursor = self.limit - v_13
        self.limit_backward = v_6
        self.cursor = self.limit_backward
        return True


class lab0(BaseException): pass


class lab1(BaseException): pass


class lab2(BaseException): pass


class lab3(BaseException): pass


class lab4(BaseException): pass


class lab5(BaseException): pass


class lab6(BaseException): pass


class lab7(BaseException): pass


class lab8(BaseException): pass


class lab9(BaseException): pass


class lab10(BaseException): pass


class lab11(BaseException): pass