(self, word)
return word
Stem a Romanian word and return the stemmed form.

        :param word: The word that is stemmed.
        :type word: str or unicode
        :return: The stemmed form.
        :rtype: unicode
Stem a Romanian word and return the stemmed form.
Stem a Romanian word and return the stemmed form .
def stem(self, word):
        """
        Stem a Romanian word and return the stemmed form.

        :param word: The word that is stemmed.
        :type word: str or unicode
        :return: The stemmed form.
        :rtype: unicode

        """
        word = word.lower()

        step1_success = False
        step2_success = False

        for i in range(1, len(word) - 1):
            if word[i - 1] in self.__vowels and word[i + 1] in self.__vowels:
                if word[i] == "u":
                    word = "".join((word[:i], "U", word[i + 1:]))

                elif word[i] == "i":
                    word = "".join((word[:i], "I", word[i + 1:]))

        r1, r2 = self._r1r2_standard(word, self.__vowels)
        rv = self._rv_standard(word, self.__vowels)

        # STEP 0: Removal of plurals and other simplifications
        for suffix in self.__step0_suffixes:
            if word.endswith(suffix):
                if suffix in r1:
                    if suffix in ("ul", "ului"):
                        word = word[:-len(suffix)]

                        if suffix in rv:
                            rv = rv[:-len(suffix)]
                        else:
                            rv = ""

                    elif (suffix == "aua" or suffix == "atei" or
                          (suffix == "ile" and word[-5:-3] != "ab")):
                        word = word[:-2]

                    elif suffix in ("ea", "ele", "elor"):
                        word = "".join((word[:-len(suffix)], "e"))

                        if suffix in rv:
                            rv = "".join((rv[:-len(suffix)], "e"))
                        else:
                            rv = ""

                    elif suffix in ("ii", "iua", "iei",
                                    "iile", "iilor", "ilor"):
                        word = "".join((word[:-len(suffix)], "i"))

                        if suffix in rv:
                            rv = "".join((rv[:-len(suffix)], "i"))
                        else:
                            rv = ""

                    elif suffix in ("a\u0163ie", "a\u0163ia"):
                        word = word[:-1]
                break

        # STEP 1: Reduction of combining suffixes
        while True:

            replacement_done = False

            for suffix in self.__step1_suffixes:
                if word.endswith(suffix):
                    if suffix in r1:
                        step1_success = True
                        replacement_done = True

                        if suffix in ("abilitate", "abilitati",
                                      "abilit\u0103i",
                                      "abilit\u0103\u0163i"):
                            word = "".join((word[:-len(suffix)], "abil"))

                        elif suffix == "ibilitate":
                            word = word[:-5]

                        elif suffix in ("ivitate", "ivitati",
                                        "ivit\u0103i",
                                        "ivit\u0103\u0163i"):
                            word = "".join((word[:-len(suffix)], "iv"))

                        elif suffix in ("icitate", "icitati", "icit\u0103i",
                                        "icit\u0103\u0163i", "icator",
                                        "icatori", "iciv", "iciva",
                                        "icive", "icivi", "iciv\u0103",
                                        "ical", "icala", "icale", "icali",
                                        "ical\u0103"):
                            word = "".join((word[:-len(suffix)], "ic"))

                        elif suffix in ("ativ", "ativa", "ative", "ativi",
                                        "ativ\u0103", "a\u0163iune",
                                        "atoare", "ator", "atori",
                                        "\u0103toare",
                                        "\u0103tor", "\u0103tori"):
                            word = "".join((word[:-len(suffix)], "at"))

                            if suffix in r2:
                                r2 = "".join((r2[:-len(suffix)], "at"))

                        elif suffix in ("itiv", "itiva", "itive", "itivi",
                                        "itiv\u0103", "i\u0163iune",
                                        "itoare", "itor", "itori"):
                            word = "".join((word[:-len(suffix)], "it"))

                            if suffix in r2:
                                r2 = "".join((r2[:-len(suffix)], "it"))
                    else:
                        step1_success = False
                    break

            if not replacement_done:
                break

        # STEP 2: Removal of standard suffixes
        for suffix in self.__step2_suffixes:
            if word.endswith(suffix):
                if suffix in r2:
                    step2_success = True

                    if suffix in ("iune", "iuni"):
                        if word[-5] == "\u0163":
                            word = "".join((word[:-5], "t"))

                    elif suffix in ("ism", "isme", "ist", "ista", "iste",
                                    "isti", "ist\u0103", "i\u015Fti"):
                        word = "".join((word[:-len(suffix)], "ist"))

                    else:
                        word = word[:-len(suffix)]
                break

        # STEP 3: Removal of verb suffixes
        if not step1_success and not step2_success:
            for suffix in self.__step3_suffixes:
                if word.endswith(suffix):
                    if suffix in rv:
                        if suffix in (u('seser\u0103\u0163i'), u('seser\u0103m'),
                                      u('ser\u0103\u0163i'), u('sese\u015Fi'),
                                      u('seser\u0103'), u('ser\u0103m'), 'sesem',
                                      u('se\u015Fi'), u('ser\u0103'), 'sese',
                                      u('a\u0163i'), u('e\u0163i'), u('i\u0163i'),
                                      u('\xE2\u0163i'), 'sei', u('\u0103m'),
                                      'em', 'im', '\xE2m', 'se'):
                            word = word[:-len(suffix)]
                            rv = rv[:-len(suffix)]
                        else:
                            if (not rv.startswith(suffix) and
                                rv[rv.index(suffix) - 1] not in
                                "aeio\u0103\xE2\xEE"):
                                word = word[:-len(suffix)]
                        break

        # STEP 4: Removal of final vowel
        for suffix in ("ie", "a", "e", "i", "\u0103"):
            if word.endswith(suffix):
                if suffix in rv:
                    word = word[:-len(suffix)]
                break

        word = word.replace("I", "i").replace("U", "u")
        return word
def stem ( self , word ) : word = word . lower ( ) step1_success = False step2_success = False for i in range ( 1 , len ( word ) - 1 ) : if word [ i - 1 ] in self . __vowels and word [ i + 1 ] in self . __vowels : if word [ i ] == "u" : word = "" . join ( ( word [ : i ] , "U" , word [ i + 1 : ] ) ) elif word [ i ] == "i" : word = "" . join ( ( word [ : i ] , "I" , word [ i + 1 : ] ) ) r1 , r2 = self . _r1r2_standard ( word , self . __vowels ) rv = self . _rv_standard ( word , self . __vowels ) # STEP 0: Removal of plurals and other simplifications for suffix in self . __step0_suffixes : if word . endswith ( suffix ) : if suffix in r1 : if suffix in ( "ul" , "ului" ) : word = word [ : - len ( suffix ) ] if suffix in rv : rv = rv [ : - len ( suffix ) ] else : rv = "" elif ( suffix == "aua" or suffix == "atei" or ( suffix == "ile" and word [ - 5 : - 3 ] != "ab" ) ) : word = word [ : - 2 ] elif suffix in ( "ea" , "ele" , "elor" ) : word = "" . join ( ( word [ : - len ( suffix ) ] , "e" ) ) if suffix in rv : rv = "" . join ( ( rv [ : - len ( suffix ) ] , "e" ) ) else : rv = "" elif suffix in ( "ii" , "iua" , "iei" , "iile" , "iilor" , "ilor" ) : word = "" . join ( ( word [ : - len ( suffix ) ] , "i" ) ) if suffix in rv : rv = "" . join ( ( rv [ : - len ( suffix ) ] , "i" ) ) else : rv = "" elif suffix in ( "a\u0163ie" , "a\u0163ia" ) : word = word [ : - 1 ] break # STEP 1: Reduction of combining suffixes while True : replacement_done = False for suffix in self . __step1_suffixes : if word . endswith ( suffix ) : if suffix in r1 : step1_success = True replacement_done = True if suffix in ( "abilitate" , "abilitati" , "abilit\u0103i" , "abilit\u0103\u0163i" ) : word = "" . join ( ( word [ : - len ( suffix ) ] , "abil" ) ) elif suffix == "ibilitate" : word = word [ : - 5 ] elif suffix in ( "ivitate" , "ivitati" , "ivit\u0103i" , "ivit\u0103\u0163i" ) : word = "" . join ( ( word [ : - len ( suffix ) ] , "iv" ) ) elif suffix in ( "icitate" , "icitati" , "icit\u0103i" , "icit\u0103\u0163i" , "icator" , "icatori" , "iciv" , "iciva" , "icive" , "icivi" , "iciv\u0103" , "ical" , "icala" , "icale" , "icali" , "ical\u0103" ) : word = "" . join ( ( word [ : - len ( suffix ) ] , "ic" ) ) elif suffix in ( "ativ" , "ativa" , "ative" , "ativi" , "ativ\u0103" , "a\u0163iune" , "atoare" , "ator" , "atori" , "\u0103toare" , "\u0103tor" , "\u0103tori" ) : word = "" . join ( ( word [ : - len ( suffix ) ] , "at" ) ) if suffix in r2 : r2 = "" . join ( ( r2 [ : - len ( suffix ) ] , "at" ) ) elif suffix in ( "itiv" , "itiva" , "itive" , "itivi" , "itiv\u0103" , "i\u0163iune" , "itoare" , "itor" , "itori" ) : word = "" . join ( ( word [ : - len ( suffix ) ] , "it" ) ) if suffix in r2 : r2 = "" . join ( ( r2 [ : - len ( suffix ) ] , "it" ) ) else : step1_success = False break if not replacement_done : break # STEP 2: Removal of standard suffixes for suffix in self . __step2_suffixes : if word . endswith ( suffix ) : if suffix in r2 : step2_success = True if suffix in ( "iune" , "iuni" ) : if word [ - 5 ] == "\u0163" : word = "" . join ( ( word [ : - 5 ] , "t" ) ) elif suffix in ( "ism" , "isme" , "ist" , "ista" , "iste" , "isti" , "ist\u0103" , "i\u015Fti" ) : word = "" . join ( ( word [ : - len ( suffix ) ] , "ist" ) ) else : word = word [ : - len ( suffix ) ] break # STEP 3: Removal of verb suffixes if not step1_success and not step2_success : for suffix in self . __step3_suffixes : if word . endswith ( suffix ) : if suffix in rv : if suffix in ( u ( 'seser\u0103\u0163i' ) , u ( 'seser\u0103m' ) , u ( 'ser\u0103\u0163i' ) , u ( 'sese\u015Fi' ) , u ( 'seser\u0103' ) , u ( 'ser\u0103m' ) , 'sesem' , u ( 'se\u015Fi' ) , u ( 'ser\u0103' ) , 'sese' , u ( 'a\u0163i' ) , u ( 'e\u0163i' ) , u ( 'i\u0163i' ) , u ( '\xE2\u0163i' ) , 'sei' , u ( '\u0103m' ) , 'em' , 'im' , '\xE2m' , 'se' ) : word = word [ : - len ( suffix ) ] rv = rv [ : - len ( suffix ) ] else : if ( not rv . startswith ( suffix ) and rv [ rv . index ( suffix ) - 1 ] not in "aeio\u0103\xE2\xEE" ) : word = word [ : - len ( suffix ) ] break # STEP 4: Removal of final vowel for suffix in ( "ie" , "a" , "e" , "i" , "\u0103" ) : if word . endswith ( suffix ) : if suffix in rv : word = word [ : - len ( suffix ) ] break word = word . replace ( "I" , "i" ) . replace ( "U" , "u" ) return word