# This file was generated automatically by the Snowball to Python compiler
# http://snowballstem.org/

from .basestemmer import BaseStemmer
from .among import Among


class ArabicStemmer(BaseStemmer):
    '''
    This class was automatically generated by a Snowball to Python compiler
    It implements the stemming algorithm defined by a snowball script.
    '''

    a_0 = [
        Among(u"\u0640", -1, 1),
        Among(u"\u064B", -1, 1),
        Among(u"\u064C", -1, 1),
        Among(u"\u064D", -1, 1),
        Among(u"\u064E", -1, 1),
        Among(u"\u064F", -1, 1),
        Among(u"\u0650", -1, 1),
        Among(u"\u0651", -1, 1),
        Among(u"\u0652", -1, 1),
        Among(u"\u0660", -1, 2),
        Among(u"\u0661", -1, 3),
        Among(u"\u0662", -1, 4),
        Among(u"\u0663", -1, 5),
        Among(u"\u0664", -1, 6),
        Among(u"\u0665", -1, 7),
        Among(u"\u0666", -1, 8),
        Among(u"\u0667", -1, 9),
        Among(u"\u0668", -1, 10),
        Among(u"\u0669", -1, 11),
        Among(u"\uFE80", -1, 12),
        Among(u"\uFE81", -1, 16),
        Among(u"\uFE82", -1, 16),
        Among(u"\uFE83", -1, 13),
        Among(u"\uFE84", -1, 13),
        Among(u"\uFE85", -1, 17),
        Among(u"\uFE86", -1, 17),
        Among(u"\uFE87", -1, 14),
        Among(u"\uFE88", -1, 14),
        Among(u"\uFE89", -1, 15),
        Among(u"\uFE8A", -1, 15),
        Among(u"\uFE8B", -1, 15),
        Among(u"\uFE8C", -1, 15),
        Among(u"\uFE8D", -1, 18),
        Among(u"\uFE8E", -1, 18),
        Among(u"\uFE8F", -1, 19),
        Among(u"\uFE90", -1, 19),
        Among(u"\uFE91", -1, 19),
        Among(u"\uFE92", -1, 19),
        Among(u"\uFE93", -1, 20),
        Among(u"\uFE94", -1, 20),
        Among(u"\uFE95", -1, 21),
        Among(u"\uFE96", -1, 21),
        Among(u"\uFE97", -1, 21),
        Among(u"\uFE98", -1, 21),
        Among(u"\uFE99", -1, 22),
        Among(u"\uFE9A", -1, 22),
        Among(u"\uFE9B", -1, 22),
        Among(u"\uFE9C", -1, 22),
        Among(u"\uFE9D", -1, 23),
        Among(u"\uFE9E", -1, 23),
        Among(u"\uFE9F", -1, 23),
        Among(u"\uFEA0", -1, 23),
        Among(u"\uFEA1", -1, 24),
        Among(u"\uFEA2", -1, 24),
        Among(u"\uFEA3", -1, 24),
        Among(u"\uFEA4", -1, 24),
        Among(u"\uFEA5", -1, 25),
        Among(u"\uFEA6", -1, 25),
        Among(u"\uFEA7", -1, 25),
        Among(u"\uFEA8", -1, 25),
        Among(u"\uFEA9", -1, 26),
        Among(u"\uFEAA", -1, 26),
        Among(u"\uFEAB", -1, 27),
        Among(u"\uFEAC", -1, 27),
        Among(u"\uFEAD", -1, 28),
        Among(u"\uFEAE", -1, 28),
        Among(u"\uFEAF", -1, 29),
        Among(u"\uFEB0", -1, 29),
        Among(u"\uFEB1", -1, 30),
        Among(u"\uFEB2", -1, 30),
        Among(u"\uFEB3", -1, 30),
        Among(u"\uFEB4", -1, 30),
        Among(u"\uFEB5", -1, 31),
        Among(u"\uFEB6", -1, 31),
        Among(u"\uFEB7", -1, 31),
        Among(u"\uFEB8", -1, 31),
        Among(u"\uFEB9", -1, 32),
        Among(u"\uFEBA", -1, 32),
        Among(u"\uFEBB", -1, 32),
        Among(u"\uFEBC", -1, 32),
        Among(u"\uFEBD", -1, 33),
        Among(u"\uFEBE", -1, 33),
        Among(u"\uFEBF", -1, 33),
        Among(u"\uFEC0", -1, 33),
        Among(u"\uFEC1", -1, 34),
        Among(u"\uFEC2", -1, 34),
        Among(u"\uFEC3", -1, 34),
        Among(u"\uFEC4", -1, 34),
        Among(u"\uFEC5", -1, 35),
        Among(u"\uFEC6", -1, 35),
        Among(u"\uFEC7", -1, 35),
        Among(u"\uFEC8", -1, 35),
        Among(u"\uFEC9", -1, 36),
        Among(u"\uFECA", -1, 36),
        Among(u"\uFECB", -1, 36),
        Among(u"\uFECC", -1, 36),
        Among(u"\uFECD", -1, 37),
        Among(u"\uFECE", -1, 37),
        Among(u"\uFECF", -1, 37),
        Among(u"\uFED0", -1, 37),
        Among(u"\uFED1", -1, 38),
        Among(u"\uFED2", -1, 38),
        Among(u"\uFED3", -1, 38),
        Among(u"\uFED4", -1, 38),
        Among(u"\uFED5", -1, 39),
        Among(u"\uFED6", -1, 39),
        Among(u"\uFED7", -1, 39),
        Among(u"\uFED8", -1, 39),
        Among(u"\uFED9", -1, 40),
        Among(u"\uFEDA", -1, 40),
        Among(u"\uFEDB", -1, 40),
        Among(u"\uFEDC", -1, 40),
        Among(u"\uFEDD", -1, 41),
        Among(u"\uFEDE", -1, 41),
        Among(u"\uFEDF", -1, 41),
        Among(u"\uFEE0", -1, 41),
        Among(u"\uFEE1", -1, 42),
        Among(u"\uFEE2", -1, 42),
        Among(u"\uFEE3", -1, 42),
        Among(u"\uFEE4", -1, 42),
        Among(u"\uFEE5", -1, 43),
        Among(u"\uFEE6", -1, 43),
        Among(u"\uFEE7", -1, 43),
        Among(u"\uFEE8", -1, 43),
        Among(u"\uFEE9", -1, 44),
        Among(u"\uFEEA", -1, 44),
        Among(u"\uFEEB", -1, 44),
        Among(u"\uFEEC", -1, 44),
        Among(u"\uFEED", -1, 45),
        Among(u"\uFEEE", -1, 45),
        Among(u"\uFEEF", -1, 46),
        Among(u"\uFEF0", -1, 46),
        Among(u"\uFEF1", -1, 47),
        Among(u"\uFEF2", -1, 47),
        Among(u"\uFEF3", -1, 47),
        Among(u"\uFEF4", -1, 47),
        Among(u"\uFEF5", -1, 51),
        Among(u"\uFEF6", -1, 51),
        Among(u"\uFEF7", -1, 49),
        Among(u"\uFEF8", -1, 49),
        Among(u"\uFEF9", -1, 50),
        Among(u"\uFEFA", -1, 50),
        Among(u"\uFEFB", -1, 48),
        Among(u"\uFEFC", -1, 48)
    ]

    a_1 = [
        Among(u"\u0622", -1, 1),
        Among(u"\u0623", -1, 1),
        Among(u"\u0624", -1, 1),
        Among(u"\u0625", -1, 1),
        Among(u"\u0626", -1, 1)
    ]

    a_2 = [
        Among(u"\u0622", -1, 1),
        Among(u"\u0623", -1, 1),
        Among(u"\u0624", -1, 2),
        Among(u"\u0625", -1, 1),
        Among(u"\u0626", -1, 3)
    ]

    a_3 = [
        Among(u"\u0627\u0644", -1, 2),
        Among(u"\u0628\u0627\u0644", -1, 1),
        Among(u"\u0643\u0627\u0644", -1, 1),
        Among(u"\u0644\u0644", -1, 2)
    ]

    a_4 = [
        Among(u"\u0623\u0622", -1, 2),
        Among(u"\u0623\u0623", -1, 1),
        Among(u"\u0623\u0624", -1, 1),
        Among(u"\u0623\u0625", -1, 4),
        Among(u"\u0623\u0627", -1, 3)
    ]

    a_5 = [
        Among(u"\u0641", -1, 1),
        Among(u"\u0648", -1, 1)
    ]

    a_6 = [
        Among(u"\u0627\u0644", -1, 2),
        Among(u"\u0628\u0627\u0644", -1, 1),
        Among(u"\u0643\u0627\u0644", -1, 1),
        Among(u"\u0644\u0644", -1, 2)
    ]

    a_7 = [
        Among(u"\u0628", -1, 1),
        Among(u"\u0628\u0628", 0, 2),
        Among(u"\u0643\u0643", -1, 3)
    ]

    a_8 = [
        Among(u"\u0633\u0623", -1, 4),
        Among(u"\u0633\u062A", -1, 2),
        Among(u"\u0633\u0646", -1, 3),
        Among(u"\u0633\u064A", -1, 1)
    ]

    a_9 = [
        Among(u"\u062A\u0633\u062A", -1, 1),
        Among(u"\u0646\u0633\u062A", -1, 1),
        Among(u"\u064A\u0633\u062A", -1, 1)
    ]

    a_10 = [
        Among(u"\u0643\u0645\u0627", -1, 3),
        Among(u"\u0647\u0645\u0627", -1, 3),
        Among(u"\u0646\u0627", -1, 2),
        Among(u"\u0647\u0627", -1, 2),
        Among(u"\u0643", -1, 1),
        Among(u"\u0643\u0645", -1, 2),
        Among(u"\u0647\u0645", -1, 2),
        Among(u"\u0647\u0646", -1, 2),
        Among(u"\u0647", -1, 1),
        Among(u"\u064A", -1, 1)
    ]

    a_11 = [
        Among(u"\u0646", -1, 1)
    ]

    a_12 = [
        Among(u"\u0627", -1, 1),
        Among(u"\u0648", -1, 1),
        Among(u"\u064A", -1, 1)
    ]

    a_13 = [
        Among(u"\u0627\u062A", -1, 1)
    ]

    a_14 = [
        Among(u"\u062A", -1, 1)
    ]

    a_15 = [
        Among(u"\u0629", -1, 1)
    ]

    a_16 = [
        Among(u"\u064A", -1, 1)
    ]

    a_17 = [
        Among(u"\u0643\u0645\u0627", -1, 3),
        Among(u"\u0647\u0645\u0627", -1, 3),
        Among(u"\u0646\u0627", -1, 2),
        Among(u"\u0647\u0627", -1, 2),
        Among(u"\u0643", -1, 1),
        Among(u"\u0643\u0645", -1, 2),
        Among(u"\u0647\u0645", -1, 2),
        Among(u"\u0643\u0646", -1, 2),
        Among(u"\u0647\u0646", -1, 2),
        Among(u"\u0647", -1, 1),
        Among(u"\u0643\u0645\u0648", -1, 3),
        Among(u"\u0646\u064A", -1, 2)
    ]

    a_18 = [
        Among(u"\u0627", -1, 1),
        Among(u"\u062A\u0627", 0, 2),
        Among(u"\u062A\u0645\u0627", 0, 4),
        Among(u"\u0646\u0627", 0, 2),
        Among(u"\u062A", -1, 1),
        Among(u"\u0646", -1, 1),
        Among(u"\u0627\u0646", 5, 3),
        Among(u"\u062A\u0646", 5, 2),
        Among(u"\u0648\u0646", 5, 3),
        Among(u"\u064A\u0646", 5, 3),
        Among(u"\u064A", -1, 1)
    ]

    a_19 = [
        Among(u"\u0648\u0627", -1, 1),
        Among(u"\u062A\u0645", -1, 1)
    ]

    a_20 = [
        Among(u"\u0648", -1, 1),
        Among(u"\u062A\u0645\u0648", 0, 2)
    ]

    a_21 = [
        Among(u"\u0649", -1, 1)
    ]

    B_is_defined = False
    B_is_verb = False
    B_is_noun = False


    def __r_Normalize_pre(self):
        # (, line 246
        # do, line 247
        v_1 = self.cursor
        try:
            # repeat, line 247
            try:
                while True:
                    try:
                        v_2 = self.cursor
                        try:
                            # (, line 247
                            # or, line 311
                            try:
                                v_3 = self.cursor
                                try:
                                    # (, line 248
                                    # [, line 249
                                    self.bra = self.cursor
                                    # substring, line 249
                                    among_var = self.find_among(ArabicStemmer.a_0)
                                    if among_var == 0:
                                        raise lab5()
                                    # ], line 249
                                    self.ket = self.cursor
                                    if among_var == 1:
                                        # (, line 250
                                        # delete, line 250
                                        if not self.slice_del():
                                            return False

                                    elif among_var == 2:
                                        # (, line 254
                                        # <-, line 254
                                        if not self.slice_from(u"0"):
                                            return False
                                    elif among_var == 3:
                                        # (, line 255
                                        # <-, line 255
                                        if not self.slice_from(u"1"):
                                            return False
                                    elif among_var == 4:
                                        # (, line 256
                                        # <-, line 256
                                        if not self.slice_from(u"2"):
                                            return False
                                    elif among_var == 5:
                                        # (, line 257
                                        # <-, line 257
                                        if not self.slice_from(u"3"):
                                            return False
                                    elif among_var == 6:
                                        # (, line 258
                                        # <-, line 258
                                        if not self.slice_from(u"4"):
                                            return False
                                    elif among_var == 7:
                                        # (, line 259
                                        # <-, line 259
                                        if not self.slice_from(u"5"):
                                            return False
                                    elif among_var == 8:
                                        # (, line 260
                                        # <-, line 260
                                        if not self.slice_from(u"6"):
                                            return False
                                    elif among_var == 9:
                                        # (, line 261
                                        # <-, line 261
                                        if not self.slice_from(u"7"):
                                            return False
                                    elif among_var == 10:
                                        # (, line 262
                                        # <-, line 262
                                        if not self.slice_from(u"8"):
                                            return False
                                    elif among_var == 11:
                                        # (, line 263
                                        # <-, line 263
                                        if not self.slice_from(u"9"):
                                            return False
                                    elif among_var == 12:
                                        # (, line 266
                                        # <-, line 266
                                        if not self.slice_from(u"\u0621"):
                                            return False
                                    elif among_var == 13:
                                        # (, line 267
                                        # <-, line 267
                                        if not self.slice_from(u"\u0623"):
                                            return False
                                    elif among_var == 14:
                                        # (, line 268
                                        # <-, line 268
                                        if not self.slice_from(u"\u0625"):
                                            return False
                                    elif among_var == 15:
                                        # (, line 269
                                        # <-, line 269
                                        if not self.slice_from(u"\u0626"):
                                            return False
                                    elif among_var == 16:
                                        # (, line 270
                                        # <-, line 270
                                        if not self.slice_from(u"\u0622"):
                                            return False
                                    elif among_var == 17:
                                        # (, line 271
                                        # <-, line 271
                                        if not self.slice_from(u"\u0624"):
                                            return False
                                    elif among_var == 18:
                                        # (, line 272
                                        # <-, line 272
                                        if not self.slice_from(u"\u0627"):
                                            return False
                                    elif among_var == 19:
                                        # (, line 273
                                        # <-, line 273
                                        if not self.slice_from(u"\u0628"):
                                            return False
                                    elif among_var == 20:
                                        # (, line 274
                                        # <-, line 274
                                        if not self.slice_from(u"\u0629"):
                                            return False
                                    elif among_var == 21:
                                        # (, line 275
                                        # <-, line 275
                                        if not self.slice_from(u"\u062A"):
                                            return False
                                    elif among_var == 22:
                                        # (, line 276
                                        # <-, line 276
                                        if not self.slice_from(u"\u062B"):
                                            return False
                                    elif among_var == 23:
                                        # (, line 277
                                        # <-, line 277
                                        if not self.slice_from(u"\u062C"):
                                            return False
                                    elif among_var == 24:
                                        # (, line 278
                                        # <-, line 278
                                        if not self.slice_from(u"\u062D"):
                                            return False
                                    elif among_var == 25:
                                        # (, line 279
                                        # <-, line 279
                                        if not self.slice_from(u"\u062E"):
                                            return False
                                    elif among_var == 26:
                                        # (, line 280
                                        # <-, line 280
                                        if not self.slice_from(u"\u062F"):
                                            return False
                                    elif among_var == 27:
                                        # (, line 281
                                        # <-, line 281
                                        if not self.slice_from(u"\u0630"):
                                            return False
                                    elif among_var == 28:
                                        # (, line 282
                                        # <-, line 282
                                        if not self.slice_from(u"\u0631"):
                                            return False
                                    elif among_var == 29:
                                        # (, line 283
                                        # <-, line 283
                                        if not self.slice_from(u"\u0632"):
                                            return False
                                    elif among_var == 30:
                                        # (, line 284
                                        # <-, line 284
                                        if not self.slice_from(u"\u0633"):
                                            return False
                                    elif among_var == 31:
                                        # (, line 285
                                        # <-, line 285
                                        if not self.slice_from(u"\u0634"):
                                            return False
                                    elif among_var == 32:
                                        # (, line 286
                                        # <-, line 286
                                        if not self.slice_from(u"\u0635"):
                                            return False
                                    elif among_var == 33:
                                        # (, line 287
                                        # <-, line 287
                                        if not self.slice_from(u"\u0636"):
                                            return False
                                    elif among_var == 34:
                                        # (, line 288
                                        # <-, line 288
                                        if not self.slice_from(u"\u0637"):
                                            return False
                                    elif among_var == 35:
                                        # (, line 289
                                        # <-, line 289
                                        if not self.slice_from(u"\u0638"):
                                            return False
                                    elif among_var == 36:
                                        # (, line 290
                                        # <-, line 290
                                        if not self.slice_from(u"\u0639"):
                                            return False
                                    elif among_var == 37:
                                        # (, line 291
                                        # <-, line 291
                                        if not self.slice_from(u"\u063A"):
                                            return False
                                    elif among_var == 38:
                                        # (, line 292
                                        # <-, line 292
                                        if not self.slice_from(u"\u0641"):
                                            return False
                                    elif among_var == 39:
                                        # (, line 293
                                        # <-, line 293
                                        if not self.slice_from(u"\u0642"):
                                            return False
                                    elif among_var == 40:
                                        # (, line 294
                                        # <-, line 294
                                        if not self.slice_from(u"\u0643"):
                                            return False
                                    elif among_var == 41:
                                        # (, line 295
                                        # <-, line 295
                                        if not self.slice_from(u"\u0644"):
                                            return False
                                    elif among_var == 42:
                                        # (, line 296
                                        # <-, line 296
                                        if not self.slice_from(u"\u0645"):
                                            return False
                                    elif among_var == 43:
                                        # (, line 297
                                        # <-, line 297
                                        if not self.slice_from(u"\u0646"):
                                            return False
                                    elif among_var == 44:
                                        # (, line 298
                                        # <-, line 298
                                        if not self.slice_from(u"\u0647"):
                                            return False
                                    elif among_var == 45:
                                        # (, line 299
                                        # <-, line 299
                                        if not self.slice_from(u"\u0648"):
                                            return False
                                    elif among_var == 46:
                                        # (, line 300
                                        # <-, line 300
                                        if not self.slice_from(u"\u0649"):
                                            return False
                                    elif among_var == 47:
                                        # (, line 301
                                        # <-, line 301
                                        if not self.slice_from(u"\u064A"):
                                            return False
                                    elif among_var == 48:
                                        # (, line 304
                                        # <-, line 304
                                        if not self.slice_from(u"\u0644\u0627"):
                                            return False
                                    elif among_var == 49:
                                        # (, line 305
                                        # <-, line 305
                                        if not self.slice_from(u"\u0644\u0623"):
                                            return False
                                    elif among_var == 50:
                                        # (, line 306
                                        # <-, line 306
                                        if not self.slice_from(u"\u0644\u0625"):
                                            return False
                                    elif among_var == 51:
                                        # (, line 307
                                        # <-, line 307
                                        if not self.slice_from(u"\u0644\u0622"):
                                            return False
                                    raise lab4()
                                except lab5: pass
                                self.cursor = v_3
                                # next, line 312
                                if self.cursor >= self.limit:
                                    raise lab3()
                                self.cursor += 1
                            except lab4: pass
                            raise lab2()
                        except lab3: pass
                        self.cursor = v_2
                        raise lab1()
                    except lab2: pass
            except lab1: pass
        except lab0: pass
        self.cursor = v_1
        return True

    def __r_Normalize_post(self):
        # (, line 316
        # do, line 318
        v_1 = self.cursor
        try:
            # (, line 318
            # backwards, line 320
            self.limit_backward = self.cursor
            self.cursor = self.limit
            # (, line 320
            # [, line 321
            self.ket = self.cursor
            # substring, line 321
            if self.find_among_b(ArabicStemmer.a_1) == 0:
                raise lab0()
            # ], line 321
            self.bra = self.cursor
            # (, line 322
            # <-, line 322
            if not self.slice_from(u"\u0621"):
                return False
            self.cursor = self.limit_backward
        except lab0: pass
        self.cursor = v_1
        # do, line 329
        v_2 = self.cursor
        try:
            # repeat, line 329
            try:
                while True:
                    try:
                        v_3 = self.cursor
                        try:
                            # (, line 329
                            # or, line 338
                            try:
                                v_4 = self.cursor
                                try:
                                    # (, line 330
                                    # [, line 332
                                    self.bra = self.cursor
                                    # substring, line 332
                                    among_var = self.find_among(ArabicStemmer.a_2)
                                    if among_var == 0:
                                        raise lab6()
                                    # ], line 332
                                    self.ket = self.cursor
                                    if among_var == 1:
                                        # (, line 333
                                        # <-, line 333
                                        if not self.slice_from(u"\u0627"):
                                            return False
                                    elif among_var == 2:
                                        # (, line 334
                                        # <-, line 334
                                        if not self.slice_from(u"\u0648"):
                                            return False
                                    elif among_var == 3:
                                        # (, line 335
                                        # <-, line 335
                                        if not self.slice_from(u"\u064A"):
                                            return False
                                    raise lab5()
                                except lab6: pass
                                self.cursor = v_4
                                # next, line 339
                                if self.cursor >= self.limit:
                                    raise lab4()
                                self.cursor += 1
                            except lab5: pass
                            raise lab3()
                        except lab4: pass
                        self.cursor = v_3
                        raise lab2()
                    except lab3: pass
            except lab2: pass
        except lab1: pass
        self.cursor = v_2
        return True

    def __r_Checks1(self):
        # (, line 344
        # [, line 345
        self.bra = self.cursor
        # substring, line 345
        among_var = self.find_among(ArabicStemmer.a_3)
        if among_var == 0:
            return False
        # ], line 345
        self.ket = self.cursor
        if among_var == 1:
            # (, line 346
            if not len(self.current) > 4:
                return False
            # set is_noun, line 346
            self.B_is_noun = True
            # unset is_verb, line 346
            self.B_is_verb = False
            # set is_defined, line 346
            self.B_is_defined = True
        elif among_var == 2:
            # (, line 347
            if not len(self.current) > 3:
                return False
            # set is_noun, line 347
            self.B_is_noun = True
            # unset is_verb, line 347
            self.B_is_verb = False
            # set is_defined, line 347
            self.B_is_defined = True
        return True

    def __r_Prefix_Step1(self):
        # (, line 353
        # [, line 354
        self.bra = self.cursor
        # substring, line 354
        among_var = self.find_among(ArabicStemmer.a_4)
        if among_var == 0:
            return False
        # ], line 354
        self.ket = self.cursor
        if among_var == 1:
            # (, line 355
            if not len(self.current) > 3:
                return False
            # <-, line 355
            if not self.slice_from(u"\u0623"):
                return False
        elif among_var == 2:
            # (, line 356
            if not len(self.current) > 3:
                return False
            # <-, line 356
            if not self.slice_from(u"\u0622"):
                return False
        elif among_var == 3:
            # (, line 358
            if not len(self.current) > 3:
                return False
            # <-, line 358
            if not self.slice_from(u"\u0627"):
                return False
        elif among_var == 4:
            # (, line 359
            if not len(self.current) > 3:
                return False
            # <-, line 359
            if not self.slice_from(u"\u0625"):
                return False
        return True

    def __r_Prefix_Step2(self):
        # (, line 364
        # not, line 365
        v_1 = self.cursor
        try:
            # literal, line 365
            if not self.eq_s(u"\u0641\u0627"):
                raise lab0()
            return False
        except lab0: pass
        self.cursor = v_1
        # not, line 366
        v_2 = self.cursor
        try:
            # literal, line 366
            if not self.eq_s(u"\u0648\u0627"):
                raise lab1()
            return False
        except lab1: pass
        self.cursor = v_2
        # [, line 367
        self.bra = self.cursor
        # substring, line 367
        if self.find_among(ArabicStemmer.a_5) == 0:
            return False
        # ], line 367
        self.ket = self.cursor
        # (, line 368
        if not len(self.current) > 3:
            return False
        # delete, line 368
        if not self.slice_del():
            return False

        return True

    def __r_Prefix_Step3a_Noun(self):
        # (, line 373
        # [, line 374
        self.bra = self.cursor
        # substring, line 374
        among_var = self.find_among(ArabicStemmer.a_6)
        if among_var == 0:
            return False
        # ], line 374
        self.ket = self.cursor
        if among_var == 1:
            # (, line 375
            if not len(self.current) > 5:
                return False
            # delete, line 375
            if not self.slice_del():
                return False

        elif among_var == 2:
            # (, line 376
            if not len(self.current) > 4:
                return False
            # delete, line 376
            if not self.slice_del():
                return False

        return True

    def __r_Prefix_Step3b_Noun(self):
        # (, line 380
        # not, line 381
        v_1 = self.cursor
        try:
            # literal, line 381
            if not self.eq_s(u"\u0628\u0627"):
                raise lab0()
            return False
        except lab0: pass
        self.cursor = v_1
        # [, line 382
        self.bra = self.cursor
        # substring, line 382
        among_var = self.find_among(ArabicStemmer.a_7)
        if among_var == 0:
            return False
        # ], line 382
        self.ket = self.cursor
        if among_var == 1:
            # (, line 383
            if not len(self.current) > 3:
                return False
            # delete, line 383
            if not self.slice_del():
                return False

        elif among_var == 2:
            # (, line 385
            if not len(self.current) > 3:
                return False
            # <-, line 385
            if not self.slice_from(u"\u0628"):
                return False
        elif among_var == 3:
            # (, line 386
            if not len(self.current) > 3:
                return False
            # <-, line 386
            if not self.slice_from(u"\u0643"):
                return False
        return True

    def __r_Prefix_Step3_Verb(self):
        # (, line 391
        # [, line 392
        self.bra = self.cursor
        # substring, line 392
        among_var = self.find_among(ArabicStemmer.a_8)
        if among_var == 0:
            return False
        # ], line 392
        self.ket = self.cursor
        if among_var == 1:
            # (, line 394
            if not len(self.current) > 4:
                return False
            # <-, line 394
            if not self.slice_from(u"\u064A"):
                return False
        elif among_var == 2:
            # (, line 395
            if not len(self.current) > 4:
                return False
            # <-, line 395
            if not self.slice_from(u"\u062A"):
                return False
        elif among_var == 3:
            # (, line 396
            if not len(self.current) > 4:
                return False
            # <-, line 396
            if not self.slice_from(u"\u0646"):
                return False
        elif among_var == 4:
            # (, line 397
            if not len(self.current) > 4:
                return False
            # <-, line 397
            if not self.slice_from(u"\u0623"):
                return False
        return True

    def __r_Prefix_Step4_Verb(self):
        # (, line 401
        # [, line 402
        self.bra = self.cursor
        # substring, line 402
        if self.find_among(ArabicStemmer.a_9) == 0:
            return False
        # ], line 402
        self.ket = self.cursor
        # (, line 403
        if not len(self.current) > 4:
            return False
        # set is_verb, line 403
        self.B_is_verb = True
        # unset is_noun, line 403
        self.B_is_noun = False
        # <-, line 403
        if not self.slice_from(u"\u0627\u0633\u062A"):
            return False
        return True

    def __r_Suffix_Noun_Step1a(self):
        # (, line 410
        # [, line 411
        self.ket = self.cursor
        # substring, line 411
        among_var = self.find_among_b(ArabicStemmer.a_10)
        if among_var == 0:
            return False
        # ], line 411
        self.bra = self.cursor
        if among_var == 1:
            # (, line 412
            if not len(self.current) >= 4:
                return False
            # delete, line 412
            if not self.slice_del():
                return False

        elif among_var == 2:
            # (, line 413
            if not len(self.current) >= 5:
                return False
            # delete, line 413
            if not self.slice_del():
                return False

        elif among_var == 3:
            # (, line 414
            if not len(self.current) >= 6:
                return False
            # delete, line 414
            if not self.slice_del():
                return False

        return True

    def __r_Suffix_Noun_Step1b(self):
        # (, line 417
        # [, line 418
        self.ket = self.cursor
        # substring, line 418
        if self.find_among_b(ArabicStemmer.a_11) == 0:
            return False
        # ], line 418
        self.bra = self.cursor
        # (, line 419
        if not len(self.current) > 5:
            return False
        # delete, line 419
        if not self.slice_del():
            return False

        return True

    def __r_Suffix_Noun_Step2a(self):
        # (, line 423
        # [, line 424
        self.ket = self.cursor
        # substring, line 424
        if self.find_among_b(ArabicStemmer.a_12) == 0:
            return False
        # ], line 424
        self.bra = self.cursor
        # (, line 425
        if not len(self.current) > 4:
            return False
        # delete, line 425
        if not self.slice_del():
            return False

        return True

    def __r_Suffix_Noun_Step2b(self):
        # (, line 429
        # [, line 430
        self.ket = self.cursor
        # substring, line 430
        if self.find_among_b(ArabicStemmer.a_13) == 0:
            return False
        # ], line 430
        self.bra = self.cursor
        # (, line 431
        if not len(self.current) >= 5:
            return False
        # delete, line 431
        if not self.slice_del():
            return False

        return True

    def __r_Suffix_Noun_Step2c1(self):
        # (, line 435
        # [, line 436
        self.ket = self.cursor
        # substring, line 436
        if self.find_among_b(ArabicStemmer.a_14) == 0:
            return False
        # ], line 436
        self.bra = self.cursor
        # (, line 437
        if not len(self.current) >= 4:
            return False
        # delete, line 437
        if not self.slice_del():
            return False

        return True

    def __r_Suffix_Noun_Step2c2(self):
        # (, line 440
        # [, line 441
        self.ket = self.cursor
        # substring, line 441
        if self.find_among_b(ArabicStemmer.a_15) == 0:
            return False
        # ], line 441
        self.bra = self.cursor
        # (, line 442
        if not len(self.current) >= 4:
            return False
        # delete, line 442
        if not self.slice_del():
            return False

        return True

    def __r_Suffix_Noun_Step3(self):
        # (, line 445
        # [, line 446
        self.ket = self.cursor
        # substring, line 446
        if self.find_among_b(ArabicStemmer.a_16) == 0:
            return False
        # ], line 446
        self.bra = self.cursor
        # (, line 447
        if not len(self.current) >= 3:
            return False
        # delete, line 447
        if not self.slice_del():
            return False

        return True

    def __r_Suffix_Verb_Step1(self):
        # (, line 451
        # [, line 452
        self.ket = self.cursor
        # substring, line 452
        among_var = self.find_among_b(ArabicStemmer.a_17)
        if among_var == 0:
            return False
        # ], line 452
        self.bra = self.cursor
        if among_var == 1:
            # (, line 453
            if not len(self.current) >= 4:
                return False
            # delete, line 453
            if not self.slice_del():
                return False

        elif among_var == 2:
            # (, line 454
            if not len(self.current) >= 5:
                return False
            # delete, line 454
            if not self.slice_del():
                return False

        elif among_var == 3:
            # (, line 455
            if not len(self.current) >= 6:
                return False
            # delete, line 455
            if not self.slice_del():
                return False

        return True

    def __r_Suffix_Verb_Step2a(self):
        # (, line 458
        # [, line 459
        self.ket = self.cursor
        # substring, line 459
        among_var = self.find_among_b(ArabicStemmer.a_18)
        if among_var == 0:
            return False
        # ], line 459
        self.bra = self.cursor
        if among_var == 1:
            # (, line 460
            if not len(self.current) >= 4:
                return False
            # delete, line 460
            if not self.slice_del():
                return False

        elif among_var == 2:
            # (, line 462
            if not len(self.current) >= 5:
                return False
            # delete, line 462
            if not self.slice_del():
                return False

        elif among_var == 3:
            # (, line 463
            if not len(self.current) > 5:
                return False
            # delete, line 463
            if not self.slice_del():
                return False

        elif among_var == 4:
            # (, line 464
            if not len(self.current) >= 6:
                return False
            # delete, line 464
            if not self.slice_del():
                return False

        return True

    def __r_Suffix_Verb_Step2b(self):
        # (, line 468
        # [, line 469
        self.ket = self.cursor
        # substring, line 469
        if self.find_among_b(ArabicStemmer.a_19) == 0:
            return False
        # ], line 469
        self.bra = self.cursor
        # (, line 470
        if not len(self.current) >= 5:
            return False
        # delete, line 470
        if not self.slice_del():
            return False

        return True

    def __r_Suffix_Verb_Step2c(self):
        # (, line 475
        # [, line 476
        self.ket = self.cursor
        # substring, line 476
        among_var = self.find_among_b(ArabicStemmer.a_20)
        if among_var == 0:
            return False
        # ], line 476
        self.bra = self.cursor
        if among_var == 1:
            # (, line 477
            if not len(self.current) >= 4:
                return False
            # delete, line 477
            if not self.slice_del():
                return False

        elif among_var == 2:
            # (, line 478
            if not len(self.current) >= 6:
                return False
            # delete, line 478
            if not self.slice_del():
                return False

        return True

    def __r_Suffix_All_alef_maqsura(self):
        # (, line 482
        # [, line 483
        self.ket = self.cursor
        # substring, line 483
        if self.find_among_b(ArabicStemmer.a_21) == 0:
            return False
        # ], line 483
        self.bra = self.cursor
        # (, line 484
        # <-, line 484
        if not self.slice_from(u"\u064A"):
            return False
        return True

    def _stem(self):
        # (, line 491
        # set is_noun, line 493
        self.B_is_noun = True
        # set is_verb, line 494
        self.B_is_verb = True
        # unset is_defined, line 495
        self.B_is_defined = False
        # do, line 498
        v_1 = self.cursor
        # call Checks1, line 498
        self.__r_Checks1()
        self.cursor = v_1
        # do, line 501
        # call Normalize_pre, line 501
        self.__r_Normalize_pre()
        # backwards, line 504
        self.limit_backward = self.cursor
        self.cursor = self.limit
        # (, line 504
        # do, line 506
        v_3 = self.limit - self.cursor
        try:
            # (, line 506
            # or, line 520
            try:
                v_4 = self.limit - self.cursor
                try:
                    # (, line 508
                    # Boolean test is_verb, line 509
                    if not self.B_is_verb:
                        raise lab2()
                    # (, line 510
                    # or, line 515
                    try:
                        v_5 = self.limit - self.cursor
                        try:
                            # (, line 511
                            # (, line 512
                            # atleast, line 512
                            v_6 = 1
                            # atleast, line 512
                            try:
                                while True:
                                    try:
                                        v_7 = self.limit - self.cursor
                                        try:
                                            # call Suffix_Verb_Step1, line 512
                                            if not self.__r_Suffix_Verb_Step1():
                                                raise lab7()
                                            v_6 -= 1
                                            raise lab6()
                                        except lab7: pass
                                        self.cursor = self.limit - v_7
                                        raise lab5()
                                    except lab6: pass
                            except lab5: pass
                            if v_6 > 0:
                                raise lab4()
                            # (, line 513
                            # or, line 513
                            try:
                                v_8 = self.limit - self.cursor
                                try:
                                    # call Suffix_Verb_Step2a, line 513
                                    if not self.__r_Suffix_Verb_Step2a():
                                        raise lab9()
                                    raise lab8()
                                except lab9: pass
                                self.cursor = self.limit - v_8
                                try:
                                    # call Suffix_Verb_Step2c, line 513
                                    if not self.__r_Suffix_Verb_Step2c():
                                        raise lab10()
                                    raise lab8()
                                except lab10: pass
                                self.cursor = self.limit - v_8
                                # next, line 513
                                if self.cursor <= self.limit_backward:
                                    raise lab4()
                                self.cursor -= 1
                            except lab8: pass
                            raise lab3()
                        except lab4: pass
                        self.cursor = self.limit - v_5
                        try:
                            # call Suffix_Verb_Step2b, line 515
                            if not self.__r_Suffix_Verb_Step2b():
                                raise lab11()
                            raise lab3()
                        except lab11: pass
                        self.cursor = self.limit - v_5
                        # call Suffix_Verb_Step2a, line 516
                        if not self.__r_Suffix_Verb_Step2a():
                            raise lab2()
                    except lab3: pass
                    raise lab1()
                except lab2: pass
                self.cursor = self.limit - v_4
                try:
                    # (, line 520
                    # Boolean test is_noun, line 521
                    if not self.B_is_noun:
                        raise lab12()
                    # (, line 522
                    # try, line 524
                    v_9 = self.limit - self.cursor
                    try:
                        # (, line 524
                        # or, line 526
                        try:
                            v_10 = self.limit - self.cursor
                            try:
                                # call Suffix_Noun_Step2c2, line 525
                                if not self.__r_Suffix_Noun_Step2c2():
                                    raise lab15()
                                raise lab14()
                            except lab15: pass
                            self.cursor = self.limit - v_10
                            try:
                                # (, line 526
                                # not, line 526
                                try:
                                    # Boolean test is_defined, line 526
                                    if not self.B_is_defined:
                                        raise lab17()
                                    raise lab16()
                                except lab17: pass
                                # call Suffix_Noun_Step1a, line 526
                                if not self.__r_Suffix_Noun_Step1a():
                                    raise lab16()
                                # (, line 526
                                # or, line 528
                                try:
                                    v_12 = self.limit - self.cursor
                                    try:
                                        # call Suffix_Noun_Step2a, line 527
                                        if not self.__r_Suffix_Noun_Step2a():
                                            raise lab19()
                                        raise lab18()
                                    except lab19: pass
                                    self.cursor = self.limit - v_12
                                    try:
                                        # call Suffix_Noun_Step2b, line 528
                                        if not self.__r_Suffix_Noun_Step2b():
                                            raise lab20()
                                        raise lab18()
                                    except lab20: pass
                                    self.cursor = self.limit - v_12
                                    try:
                                        # call Suffix_Noun_Step2c1, line 529
                                        if not self.__r_Suffix_Noun_Step2c1():
                                            raise lab21()
                                        raise lab18()
                                    except lab21: pass
                                    self.cursor = self.limit - v_12
                                    # next, line 530
                                    if self.cursor <= self.limit_backward:
                                        raise lab16()
                                    self.cursor -= 1
                                except lab18: pass
                                raise lab14()
                            except lab16: pass
                            self.cursor = self.limit - v_10
                            try:
                                # (, line 531
                                # call Suffix_Noun_Step1b, line 531
                                if not self.__r_Suffix_Noun_Step1b():
                                    raise lab22()
                                # (, line 531
                                # or, line 533
                                try:
                                    v_13 = self.limit - self.cursor
                                    try:
                                        # call Suffix_Noun_Step2a, line 532
                                        if not self.__r_Suffix_Noun_Step2a():
                                            raise lab24()
                                        raise lab23()
                                    except lab24: pass
                                    self.cursor = self.limit - v_13
                                    try:
                                        # call Suffix_Noun_Step2b, line 533
                                        if not self.__r_Suffix_Noun_Step2b():
                                            raise lab25()
                                        raise lab23()
                                    except lab25: pass
                                    self.cursor = self.limit - v_13
                                    # call Suffix_Noun_Step2c1, line 534
                                    if not self.__r_Suffix_Noun_Step2c1():
                                        raise lab22()
                                except lab23: pass
                                raise lab14()
                            except lab22: pass
                            self.cursor = self.limit - v_10
                            try:
                                # (, line 535
                                # not, line 535
                                try:
                                    # Boolean test is_defined, line 535
                                    if not self.B_is_defined:
                                        raise lab27()
                                    raise lab26()
                                except lab27: pass
                                # call Suffix_Noun_Step2a, line 535
                                if not self.__r_Suffix_Noun_Step2a():
                                    raise lab26()
                                raise lab14()
                            except lab26: pass
                            self.cursor = self.limit - v_10
                            # (, line 536
                            # call Suffix_Noun_Step2b, line 536
                            if not self.__r_Suffix_Noun_Step2b():
                                self.cursor = self.limit - v_9
                                raise lab13()
                        except lab14: pass
                    except lab13: pass
                    # call Suffix_Noun_Step3, line 538
                    if not self.__r_Suffix_Noun_Step3():
                        raise lab12()
                    raise lab1()
                except lab12: pass
                self.cursor = self.limit - v_4
                # call Suffix_All_alef_maqsura, line 544
                if not self.__r_Suffix_All_alef_maqsura():
                    raise lab0()
            except lab1: pass
        except lab0: pass
        self.cursor = self.limit - v_3
        self.cursor = self.limit_backward
        # do, line 549
        v_15 = self.cursor
        try:
            # (, line 549
            # try, line 550
            v_16 = self.cursor
            try:
                # call Prefix_Step1, line 550
                if not self.__r_Prefix_Step1():
                    self.cursor = v_16
                    raise lab29()
            except lab29: pass
            # try, line 551
            v_17 = self.cursor
            try:
                # call Prefix_Step2, line 551
                if not self.__r_Prefix_Step2():
                    self.cursor = v_17
                    raise lab30()
            except lab30: pass
            # (, line 552
            # or, line 553
            try:
                v_18 = self.cursor
                try:
                    # call Prefix_Step3a_Noun, line 552
                    if not self.__r_Prefix_Step3a_Noun():
                        raise lab32()
                    raise lab31()
                except lab32: pass
                self.cursor = v_18
                try:
                    # (, line 553
                    # Boolean test is_noun, line 553
                    if not self.B_is_noun:
                        raise lab33()
                    # call Prefix_Step3b_Noun, line 553
                    if not self.__r_Prefix_Step3b_Noun():
                        raise lab33()
                    raise lab31()
                except lab33: pass
                self.cursor = v_18
                # (, line 554
                # Boolean test is_verb, line 554
                if not self.B_is_verb:
                    raise lab28()
                # try, line 554
                v_19 = self.cursor
                try:
                    # call Prefix_Step3_Verb, line 554
                    if not self.__r_Prefix_Step3_Verb():
                        self.cursor = v_19
                        raise lab34()
                except lab34: pass
                # call Prefix_Step4_Verb, line 554
                if not self.__r_Prefix_Step4_Verb():
                    raise lab28()
            except lab31: pass
        except lab28: pass
        self.cursor = v_15
        # do, line 559
        # call Normalize_post, line 559
        self.__r_Normalize_post()
        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


class lab12(BaseException): pass


class lab13(BaseException): pass


class lab14(BaseException): pass


class lab15(BaseException): pass


class lab16(BaseException): pass


class lab17(BaseException): pass


class lab18(BaseException): pass


class lab19(BaseException): pass


class lab20(BaseException): pass


class lab21(BaseException): pass


class lab22(BaseException): pass


class lab23(BaseException): pass


class lab24(BaseException): pass


class lab25(BaseException): pass


class lab26(BaseException): pass


class lab27(BaseException): pass


class lab28(BaseException): pass


class lab29(BaseException): pass


class lab30(BaseException): pass


class lab31(BaseException): pass


class lab32(BaseException): pass


class lab33(BaseException): pass


class lab34(BaseException): pass
