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
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
# Generated by Snowball 2.2.0 - https://snowballstem.org/

from .basestemmer import BaseStemmer
from .among import Among


class ItalianStemmer(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"", -1, 7),
        Among(u"qu", 0, 6),
        Among(u"\u00E1", 0, 1),
        Among(u"\u00E9", 0, 2),
        Among(u"\u00ED", 0, 3),
        Among(u"\u00F3", 0, 4),
        Among(u"\u00FA", 0, 5)
    ]

    a_1 = [
        Among(u"", -1, 3),
        Among(u"I", 0, 1),
        Among(u"U", 0, 2)
    ]

    a_2 = [
        Among(u"la", -1, -1),
        Among(u"cela", 0, -1),
        Among(u"gliela", 0, -1),
        Among(u"mela", 0, -1),
        Among(u"tela", 0, -1),
        Among(u"vela", 0, -1),
        Among(u"le", -1, -1),
        Among(u"cele", 6, -1),
        Among(u"gliele", 6, -1),
        Among(u"mele", 6, -1),
        Among(u"tele", 6, -1),
        Among(u"vele", 6, -1),
        Among(u"ne", -1, -1),
        Among(u"cene", 12, -1),
        Among(u"gliene", 12, -1),
        Among(u"mene", 12, -1),
        Among(u"sene", 12, -1),
        Among(u"tene", 12, -1),
        Among(u"vene", 12, -1),
        Among(u"ci", -1, -1),
        Among(u"li", -1, -1),
        Among(u"celi", 20, -1),
        Among(u"glieli", 20, -1),
        Among(u"meli", 20, -1),
        Among(u"teli", 20, -1),
        Among(u"veli", 20, -1),
        Among(u"gli", 20, -1),
        Among(u"mi", -1, -1),
        Among(u"si", -1, -1),
        Among(u"ti", -1, -1),
        Among(u"vi", -1, -1),
        Among(u"lo", -1, -1),
        Among(u"celo", 31, -1),
        Among(u"glielo", 31, -1),
        Among(u"melo", 31, -1),
        Among(u"telo", 31, -1),
        Among(u"velo", 31, -1)
    ]

    a_3 = [
        Among(u"ando", -1, 1),
        Among(u"endo", -1, 1),
        Among(u"ar", -1, 2),
        Among(u"er", -1, 2),
        Among(u"ir", -1, 2)
    ]

    a_4 = [
        Among(u"ic", -1, -1),
        Among(u"abil", -1, -1),
        Among(u"os", -1, -1),
        Among(u"iv", -1, 1)
    ]

    a_5 = [
        Among(u"ic", -1, 1),
        Among(u"abil", -1, 1),
        Among(u"iv", -1, 1)
    ]

    a_6 = [
        Among(u"ica", -1, 1),
        Among(u"logia", -1, 3),
        Among(u"osa", -1, 1),
        Among(u"ista", -1, 1),
        Among(u"iva", -1, 9),
        Among(u"anza", -1, 1),
        Among(u"enza", -1, 5),
        Among(u"ice", -1, 1),
        Among(u"atrice", 7, 1),
        Among(u"iche", -1, 1),
        Among(u"logie", -1, 3),
        Among(u"abile", -1, 1),
        Among(u"ibile", -1, 1),
        Among(u"usione", -1, 4),
        Among(u"azione", -1, 2),
        Among(u"uzione", -1, 4),
        Among(u"atore", -1, 2),
        Among(u"ose", -1, 1),
        Among(u"ante", -1, 1),
        Among(u"mente", -1, 1),
        Among(u"amente", 19, 7),
        Among(u"iste", -1, 1),
        Among(u"ive", -1, 9),
        Among(u"anze", -1, 1),
        Among(u"enze", -1, 5),
        Among(u"ici", -1, 1),
        Among(u"atrici", 25, 1),
        Among(u"ichi", -1, 1),
        Among(u"abili", -1, 1),
        Among(u"ibili", -1, 1),
        Among(u"ismi", -1, 1),
        Among(u"usioni", -1, 4),
        Among(u"azioni", -1, 2),
        Among(u"uzioni", -1, 4),
        Among(u"atori", -1, 2),
        Among(u"osi", -1, 1),
        Among(u"anti", -1, 1),
        Among(u"amenti", -1, 6),
        Among(u"imenti", -1, 6),
        Among(u"isti", -1, 1),
        Among(u"ivi", -1, 9),
        Among(u"ico", -1, 1),
        Among(u"ismo", -1, 1),
        Among(u"oso", -1, 1),
        Among(u"amento", -1, 6),
        Among(u"imento", -1, 6),
        Among(u"ivo", -1, 9),
        Among(u"it\u00E0", -1, 8),
        Among(u"ist\u00E0", -1, 1),
        Among(u"ist\u00E8", -1, 1),
        Among(u"ist\u00EC", -1, 1)
    ]

    a_7 = [
        Among(u"isca", -1, 1),
        Among(u"enda", -1, 1),
        Among(u"ata", -1, 1),
        Among(u"ita", -1, 1),
        Among(u"uta", -1, 1),
        Among(u"ava", -1, 1),
        Among(u"eva", -1, 1),
        Among(u"iva", -1, 1),
        Among(u"erebbe", -1, 1),
        Among(u"irebbe", -1, 1),
        Among(u"isce", -1, 1),
        Among(u"ende", -1, 1),
        Among(u"are", -1, 1),
        Among(u"ere", -1, 1),
        Among(u"ire", -1, 1),
        Among(u"asse", -1, 1),
        Among(u"ate", -1, 1),
        Among(u"avate", 16, 1),
        Among(u"evate", 16, 1),
        Among(u"ivate", 16, 1),
        Among(u"ete", -1, 1),
        Among(u"erete", 20, 1),
        Among(u"irete", 20, 1),
        Among(u"ite", -1, 1),
        Among(u"ereste", -1, 1),
        Among(u"ireste", -1, 1),
        Among(u"ute", -1, 1),
        Among(u"erai", -1, 1),
        Among(u"irai", -1, 1),
        Among(u"isci", -1, 1),
        Among(u"endi", -1, 1),
        Among(u"erei", -1, 1),
        Among(u"irei", -1, 1),
        Among(u"assi", -1, 1),
        Among(u"ati", -1, 1),
        Among(u"iti", -1, 1),
        Among(u"eresti", -1, 1),
        Among(u"iresti", -1, 1),
        Among(u"uti", -1, 1),
        Among(u"avi", -1, 1),
        Among(u"evi", -1, 1),
        Among(u"ivi", -1, 1),
        Among(u"isco", -1, 1),
        Among(u"ando", -1, 1),
        Among(u"endo", -1, 1),
        Among(u"Yamo", -1, 1),
        Among(u"iamo", -1, 1),
        Among(u"avamo", -1, 1),
        Among(u"evamo", -1, 1),
        Among(u"ivamo", -1, 1),
        Among(u"eremo", -1, 1),
        Among(u"iremo", -1, 1),
        Among(u"assimo", -1, 1),
        Among(u"ammo", -1, 1),
        Among(u"emmo", -1, 1),
        Among(u"eremmo", 54, 1),
        Among(u"iremmo", 54, 1),
        Among(u"immo", -1, 1),
        Among(u"ano", -1, 1),
        Among(u"iscano", 58, 1),
        Among(u"avano", 58, 1),
        Among(u"evano", 58, 1),
        Among(u"ivano", 58, 1),
        Among(u"eranno", -1, 1),
        Among(u"iranno", -1, 1),
        Among(u"ono", -1, 1),
        Among(u"iscono", 65, 1),
        Among(u"arono", 65, 1),
        Among(u"erono", 65, 1),
        Among(u"irono", 65, 1),
        Among(u"erebbero", -1, 1),
        Among(u"irebbero", -1, 1),
        Among(u"assero", -1, 1),
        Among(u"essero", -1, 1),
        Among(u"issero", -1, 1),
        Among(u"ato", -1, 1),
        Among(u"ito", -1, 1),
        Among(u"uto", -1, 1),
        Among(u"avo", -1, 1),
        Among(u"evo", -1, 1),
        Among(u"ivo", -1, 1),
        Among(u"ar", -1, 1),
        Among(u"ir", -1, 1),
        Among(u"er\u00E0", -1, 1),
        Among(u"ir\u00E0", -1, 1),
        Among(u"er\u00F2", -1, 1),
        Among(u"ir\u00F2", -1, 1)
    ]

    g_v = [17, 65, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 8, 2, 1]

    g_AEIO = [17, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 8, 2]

    g_CG = [17]

    I_p2 = 0
    I_p1 = 0
    I_pV = 0

    def __r_prelude(self):
        v_1 = self.cursor
        while True:
            v_2 = self.cursor
            try:
                self.bra = self.cursor
                among_var = self.find_among(ItalianStemmer.a_0)
                if among_var == 0:
                    raise lab0()
                self.ket = self.cursor
                if among_var == 1:
                    if not self.slice_from(u"\u00E0"):
                        return False
                elif among_var == 2:
                    if not self.slice_from(u"\u00E8"):
                        return False
                elif among_var == 3:
                    if not self.slice_from(u"\u00EC"):
                        return False
                elif among_var == 4:
                    if not self.slice_from(u"\u00F2"):
                        return False
                elif among_var == 5:
                    if not self.slice_from(u"\u00F9"):
                        return False
                elif among_var == 6:
                    if not self.slice_from(u"qU"):
                        return False
                else:
                    if self.cursor >= self.limit:
                        raise lab0()
                    self.cursor += 1
                continue
            except lab0: pass
            self.cursor = v_2
            break
        self.cursor = v_1
        while True:
            v_3 = self.cursor
            try:
                try:
                    while True:
                        v_4 = self.cursor
                        try:
                            if not self.in_grouping(ItalianStemmer.g_v, 97, 249):
                                raise lab3()
                            self.bra = self.cursor
                            try:
                                v_5 = self.cursor
                                try:
                                    if not self.eq_s(u"u"):
                                        raise lab5()
                                    self.ket = self.cursor
                                    if not self.in_grouping(ItalianStemmer.g_v, 97, 249):
                                        raise lab5()
                                    if not self.slice_from(u"U"):
                                        return False
                                    raise lab4()
                                except lab5: pass
                                self.cursor = v_5
                                if not self.eq_s(u"i"):
                                    raise lab3()
                                self.ket = self.cursor
                                if not self.in_grouping(ItalianStemmer.g_v, 97, 249):
                                    raise lab3()
                                if not self.slice_from(u"I"):
                                    return False
                            except lab4: pass
                            self.cursor = v_4
                            raise lab2()
                        except lab3: pass
                        self.cursor = v_4
                        if self.cursor >= self.limit:
                            raise lab1()
                        self.cursor += 1
                except lab2: pass
                continue
            except lab1: pass
            self.cursor = v_3
            break
        return True

    def __r_mark_regions(self):
        self.I_pV = self.limit
        self.I_p1 = self.limit
        self.I_p2 = self.limit
        v_1 = self.cursor
        try:
            try:
                v_2 = self.cursor
                try:
                    if not self.in_grouping(ItalianStemmer.g_v, 97, 249):
                        raise lab2()
                    try:
                        v_3 = self.cursor
                        try:
                            if not self.out_grouping(ItalianStemmer.g_v, 97, 249):
                                raise lab4()
                            if not self.go_out_grouping(ItalianStemmer.g_v, 97, 249):
                                raise lab4()
                            self.cursor += 1
                            raise lab3()
                        except lab4: pass
                        self.cursor = v_3
                        if not self.in_grouping(ItalianStemmer.g_v, 97, 249):
                            raise lab2()
                        if not self.go_in_grouping(ItalianStemmer.g_v, 97, 249):
                            raise lab2()
                        self.cursor += 1
                    except lab3: pass
                    raise lab1()
                except lab2: pass
                self.cursor = v_2
                if not self.out_grouping(ItalianStemmer.g_v, 97, 249):
                    raise lab0()
                try:
                    v_4 = self.cursor
                    try:
                        if not self.out_grouping(ItalianStemmer.g_v, 97, 249):
                            raise lab6()
                        if not self.go_out_grouping(ItalianStemmer.g_v, 97, 249):
                            raise lab6()
                        self.cursor += 1
                        raise lab5()
                    except lab6: pass
                    self.cursor = v_4
                    if not self.in_grouping(ItalianStemmer.g_v, 97, 249):
                        raise lab0()
                    if self.cursor >= self.limit:
                        raise lab0()
                    self.cursor += 1
                except lab5: pass
            except lab1: pass
            self.I_pV = self.cursor
        except lab0: pass
        self.cursor = v_1
        v_5 = self.cursor
        try:
            if not self.go_out_grouping(ItalianStemmer.g_v, 97, 249):
                raise lab7()
            self.cursor += 1
            if not self.go_in_grouping(ItalianStemmer.g_v, 97, 249):
                raise lab7()
            self.cursor += 1
            self.I_p1 = self.cursor
            if not self.go_out_grouping(ItalianStemmer.g_v, 97, 249):
                raise lab7()
            self.cursor += 1
            if not self.go_in_grouping(ItalianStemmer.g_v, 97, 249):
                raise lab7()
            self.cursor += 1
            self.I_p2 = self.cursor
        except lab7: pass
        self.cursor = v_5
        return True

    def __r_postlude(self):
        while True:
            v_1 = self.cursor
            try:
                self.bra = self.cursor
                among_var = self.find_among(ItalianStemmer.a_1)
                if among_var == 0:
                    raise lab0()
                self.ket = self.cursor
                if among_var == 1:
                    if not self.slice_from(u"i"):
                        return False
                elif among_var == 2:
                    if not self.slice_from(u"u"):
                        return False
                else:
                    if self.cursor >= self.limit:
                        raise lab0()
                    self.cursor += 1
                continue
            except lab0: pass
            self.cursor = v_1
            break
        return True

    def __r_RV(self):
        if not self.I_pV <= self.cursor:
            return False
        return True

    def __r_R1(self):
        if not self.I_p1 <= self.cursor:
            return False
        return True

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

    def __r_attached_pronoun(self):
        self.ket = self.cursor
        if self.find_among_b(ItalianStemmer.a_2) == 0:
            return False
        self.bra = self.cursor
        among_var = self.find_among_b(ItalianStemmer.a_3)
        if among_var == 0:
            return False
        if not self.__r_RV():
            return False
        if among_var == 1:
            if not self.slice_del():
                return False

        else:
            if not self.slice_from(u"e"):
                return False
        return True

    def __r_standard_suffix(self):
        self.ket = self.cursor
        among_var = self.find_among_b(ItalianStemmer.a_6)
        if among_var == 0:
            return False
        self.bra = self.cursor
        if among_var == 1:
            if not self.__r_R2():
                return False
            if not self.slice_del():
                return False

        elif among_var == 2:
            if not self.__r_R2():
                return False
            if not self.slice_del():
                return False

            v_1 = self.limit - self.cursor
            try:
                self.ket = self.cursor
                if not self.eq_s_b(u"ic"):
                    self.cursor = self.limit - v_1
                    raise lab0()
                self.bra = self.cursor
                if not self.__r_R2():
                    self.cursor = self.limit - v_1
                    raise lab0()
                if not self.slice_del():
                    return False

            except lab0: pass
        elif among_var == 3:
            if not self.__r_R2():
                return False
            if not self.slice_from(u"log"):
                return False
        elif among_var == 4:
            if not self.__r_R2():
                return False
            if not self.slice_from(u"u"):
                return False
        elif among_var == 5:
            if not self.__r_R2():
                return False
            if not self.slice_from(u"ente"):
                return False
        elif among_var == 6:
            if not self.__r_RV():
                return False
            if not self.slice_del():
                return False

        elif among_var == 7:
            if not self.__r_R1():
                return False
            if not self.slice_del():
                return False

            v_2 = self.limit - self.cursor
            try:
                self.ket = self.cursor
                among_var = self.find_among_b(ItalianStemmer.a_4)
                if among_var == 0:
                    self.cursor = self.limit - v_2
                    raise lab1()
                self.bra = self.cursor
                if not self.__r_R2():
                    self.cursor = self.limit - v_2
                    raise lab1()
                if not self.slice_del():
                    return False

                if among_var == 1:
                    self.ket = self.cursor
                    if not self.eq_s_b(u"at"):
                        self.cursor = self.limit - v_2
                        raise lab1()
                    self.bra = self.cursor
                    if not self.__r_R2():
                        self.cursor = self.limit - v_2
                        raise lab1()
                    if not self.slice_del():
                        return False

            except lab1: pass
        elif among_var == 8:
            if not self.__r_R2():
                return False
            if not self.slice_del():
                return False

            v_3 = self.limit - self.cursor
            try:
                self.ket = self.cursor
                if self.find_among_b(ItalianStemmer.a_5) == 0:
                    self.cursor = self.limit - v_3
                    raise lab2()
                self.bra = self.cursor
                if not self.__r_R2():
                    self.cursor = self.limit - v_3
                    raise lab2()
                if not self.slice_del():
                    return False

            except lab2: pass
        else:
            if not self.__r_R2():
                return False
            if not self.slice_del():
                return False

            v_4 = self.limit - self.cursor
            try:
                self.ket = self.cursor
                if not self.eq_s_b(u"at"):
                    self.cursor = self.limit - v_4
                    raise lab3()
                self.bra = self.cursor
                if not self.__r_R2():
                    self.cursor = self.limit - v_4
                    raise lab3()
                if not self.slice_del():
                    return False

                self.ket = self.cursor
                if not self.eq_s_b(u"ic"):
                    self.cursor = self.limit - v_4
                    raise lab3()
                self.bra = self.cursor
                if not self.__r_R2():
                    self.cursor = self.limit - v_4
                    raise lab3()
                if not self.slice_del():
                    return False

            except lab3: pass
        return True

    def __r_verb_suffix(self):
        if self.cursor < self.I_pV:
            return False
        v_2 = self.limit_backward
        self.limit_backward = self.I_pV
        self.ket = self.cursor
        if self.find_among_b(ItalianStemmer.a_7) == 0:
            self.limit_backward = v_2
            return False
        self.bra = self.cursor
        if not self.slice_del():
            return False

        self.limit_backward = v_2
        return True

    def __r_vowel_suffix(self):
        v_1 = self.limit - self.cursor
        try:
            self.ket = self.cursor
            if not self.in_grouping_b(ItalianStemmer.g_AEIO, 97, 242):
                self.cursor = self.limit - v_1
                raise lab0()
            self.bra = self.cursor
            if not self.__r_RV():
                self.cursor = self.limit - v_1
                raise lab0()
            if not self.slice_del():
                return False

            self.ket = self.cursor
            if not self.eq_s_b(u"i"):
                self.cursor = self.limit - v_1
                raise lab0()
            self.bra = self.cursor
            if not self.__r_RV():
                self.cursor = self.limit - v_1
                raise lab0()
            if not self.slice_del():
                return False

        except lab0: pass
        v_2 = self.limit - self.cursor
        try:
            self.ket = self.cursor
            if not self.eq_s_b(u"h"):
                self.cursor = self.limit - v_2
                raise lab1()
            self.bra = self.cursor
            if not self.in_grouping_b(ItalianStemmer.g_CG, 99, 103):
                self.cursor = self.limit - v_2
                raise lab1()
            if not self.__r_RV():
                self.cursor = self.limit - v_2
                raise lab1()
            if not self.slice_del():
                return False

        except lab1: pass
        return True

    def _stem(self):
        v_1 = self.cursor
        self.__r_prelude()
        self.cursor = v_1
        self.__r_mark_regions()
        self.limit_backward = self.cursor
        self.cursor = self.limit
        v_3 = self.limit - self.cursor
        self.__r_attached_pronoun()
        self.cursor = self.limit - v_3
        v_4 = self.limit - self.cursor
        try:
            try:
                v_5 = self.limit - self.cursor
                try:
                    if not self.__r_standard_suffix():
                        raise lab2()
                    raise lab1()
                except lab2: pass
                self.cursor = self.limit - v_5
                if not self.__r_verb_suffix():
                    raise lab0()
            except lab1: pass
        except lab0: pass
        self.cursor = self.limit - v_4
        v_6 = self.limit - self.cursor
        self.__r_vowel_suffix()
        self.cursor = self.limit - v_6
        self.cursor = self.limit_backward
        v_7 = self.cursor
        self.__r_postlude()
        self.cursor = v_7
        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