(self, word)
return word
Stem a Russian 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 Russian word and return the stemmed form.
Stem a Russian word and return the stemmed form .
def stem(self, word):
        """
        Stem a Russian word and return the stemmed form.

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

        """
        chr_exceeded = False
        for i in range(len(word)):
            if ord(word[i]) > 255:
                chr_exceeded = True
                break

        if chr_exceeded:
            word = self.__cyrillic_to_roman(word)

        step1_success = False
        adjectival_removed = False
        verb_removed = False
        undouble_success = False
        superlative_removed = False

        rv, r2 = self.__regions_russian(word)

        # Step 1
        for suffix in self.__perfective_gerund_suffixes:
            if rv.endswith(suffix):
                if suffix in ("v", "vshi", "vshis'"):
                    if (rv[-len(suffix) - 3:-len(suffix)] == "i^a" or
                        rv[-len(suffix) - 1:-len(suffix)] == "a"):
                        word = word[:-len(suffix)]
                        r2 = r2[:-len(suffix)]
                        rv = rv[:-len(suffix)]
                        step1_success = True
                        break
                else:
                    word = word[:-len(suffix)]
                    r2 = r2[:-len(suffix)]
                    rv = rv[:-len(suffix)]
                    step1_success = True
                    break

        if not step1_success:
            for suffix in self.__reflexive_suffixes:
                if rv.endswith(suffix):
                    word = word[:-len(suffix)]
                    r2 = r2[:-len(suffix)]
                    rv = rv[:-len(suffix)]
                    break

            for suffix in self.__adjectival_suffixes:
                if rv.endswith(suffix):
                    if suffix in ('i^ushchi^ui^u', 'i^ushchi^ai^a',
                              'i^ushchui^u', 'i^ushchai^a', 'i^ushchoi^u',
                              'i^ushchei^u', 'i^ushchimi', 'i^ushchymi',
                              'i^ushchego', 'i^ushchogo', 'i^ushchemu',
                              'i^ushchomu', 'i^ushchikh', 'i^ushchykh',
                              'shchi^ui^u', 'shchi^ai^a', 'i^ushchee',
                              'i^ushchie', 'i^ushchye', 'i^ushchoe',
                              'i^ushchei`', 'i^ushchii`', 'i^ushchyi`',
                              'i^ushchoi`', 'i^ushchem', 'i^ushchim',
                              'i^ushchym', 'i^ushchom', 'vshi^ui^u',
                              'vshi^ai^a', 'shchui^u', 'shchai^a',
                              'shchoi^u', 'shchei^u', 'emi^ui^u',
                              'emi^ai^a', 'nni^ui^u', 'nni^ai^a',
                              'shchimi', 'shchymi', 'shchego', 'shchogo',
                              'shchemu', 'shchomu', 'shchikh', 'shchykh',
                              'vshui^u', 'vshai^a', 'vshoi^u', 'vshei^u',
                              'shchee', 'shchie', 'shchye', 'shchoe',
                              'shchei`', 'shchii`', 'shchyi`', 'shchoi`',
                              'shchem', 'shchim', 'shchym', 'shchom',
                              'vshimi', 'vshymi', 'vshego', 'vshogo',
                              'vshemu', 'vshomu', 'vshikh', 'vshykh',
                              'emui^u', 'emai^a', 'emoi^u', 'emei^u',
                              'nnui^u', 'nnai^a', 'nnoi^u', 'nnei^u',
                              'vshee', 'vshie', 'vshye', 'vshoe',
                              'vshei`', 'vshii`', 'vshyi`', 'vshoi`',
                              'vshem', 'vshim', 'vshym', 'vshom',
                              'emimi', 'emymi', 'emego', 'emogo',
                              'ememu', 'emomu', 'emikh', 'emykh',
                              'nnimi', 'nnymi', 'nnego', 'nnogo',
                              'nnemu', 'nnomu', 'nnikh', 'nnykh',
                              'emee', 'emie', 'emye', 'emoe', 'emei`',
                              'emii`', 'emyi`', 'emoi`', 'emem', 'emim',
                              'emym', 'emom', 'nnee', 'nnie', 'nnye',
                              'nnoe', 'nnei`', 'nnii`', 'nnyi`', 'nnoi`',
                              'nnem', 'nnim', 'nnym', 'nnom'):
                        if (rv[-len(suffix) - 3:-len(suffix)] == "i^a" or
                            rv[-len(suffix) - 1:-len(suffix)] == "a"):
                            word = word[:-len(suffix)]
                            r2 = r2[:-len(suffix)]
                            rv = rv[:-len(suffix)]
                            adjectival_removed = True
                            break
                    else:
                        word = word[:-len(suffix)]
                        r2 = r2[:-len(suffix)]
                        rv = rv[:-len(suffix)]
                        adjectival_removed = True
                        break

            if not adjectival_removed:
                for suffix in self.__verb_suffixes:
                    if rv.endswith(suffix):
                        if suffix in ("la", "na", "ete", "i`te", "li",
                                      "i`", "l", "em", "n", "lo", "no",
                                      "et", "i^ut", "ny", "t'", "esh'",
                                      "nno"):
                            if (rv[-len(suffix) - 3:-len(suffix)] == "i^a" or
                                rv[-len(suffix) - 1:-len(suffix)] == "a"):
                                word = word[:-len(suffix)]
                                r2 = r2[:-len(suffix)]
                                rv = rv[:-len(suffix)]
                                verb_removed = True
                                break
                        else:
                            word = word[:-len(suffix)]
                            r2 = r2[:-len(suffix)]
                            rv = rv[:-len(suffix)]
                            verb_removed = True
                            break

            if not adjectival_removed and not verb_removed:
                for suffix in self.__noun_suffixes:
                    if rv.endswith(suffix):
                        word = word[:-len(suffix)]
                        r2 = r2[:-len(suffix)]
                        rv = rv[:-len(suffix)]
                        break

        # Step 2
        if rv.endswith("i"):
            word = word[:-1]
            r2 = r2[:-1]

        # Step 3
        for suffix in self.__derivational_suffixes:
            if r2.endswith(suffix):
                word = word[:-len(suffix)]
                break

        # Step 4
        if word.endswith("nn"):
            word = word[:-1]
            undouble_success = True

        if not undouble_success:
            for suffix in self.__superlative_suffixes:
                if word.endswith(suffix):
                    word = word[:-len(suffix)]
                    superlative_removed = True
                    break
            if word.endswith("nn"):
                word = word[:-1]

        if not undouble_success and not superlative_removed:
            if word.endswith("'"):
                word = word[:-1]

        if chr_exceeded:
            word = self.__roman_to_cyrillic(word)
        return word
def stem ( self , word ) : chr_exceeded = False for i in range ( len ( word ) ) : if ord ( word [ i ] ) > 255 : chr_exceeded = True break if chr_exceeded : word = self . __cyrillic_to_roman ( word ) step1_success = False adjectival_removed = False verb_removed = False undouble_success = False superlative_removed = False rv , r2 = self . __regions_russian ( word ) # Step 1 for suffix in self . __perfective_gerund_suffixes : if rv . endswith ( suffix ) : if suffix in ( "v" , "vshi" , "vshis'" ) : if ( rv [ - len ( suffix ) - 3 : - len ( suffix ) ] == "i^a" or rv [ - len ( suffix ) - 1 : - len ( suffix ) ] == "a" ) : word = word [ : - len ( suffix ) ] r2 = r2 [ : - len ( suffix ) ] rv = rv [ : - len ( suffix ) ] step1_success = True break else : word = word [ : - len ( suffix ) ] r2 = r2 [ : - len ( suffix ) ] rv = rv [ : - len ( suffix ) ] step1_success = True break if not step1_success : for suffix in self . __reflexive_suffixes : if rv . endswith ( suffix ) : word = word [ : - len ( suffix ) ] r2 = r2 [ : - len ( suffix ) ] rv = rv [ : - len ( suffix ) ] break for suffix in self . __adjectival_suffixes : if rv . endswith ( suffix ) : if suffix in ( 'i^ushchi^ui^u' , 'i^ushchi^ai^a' , 'i^ushchui^u' , 'i^ushchai^a' , 'i^ushchoi^u' , 'i^ushchei^u' , 'i^ushchimi' , 'i^ushchymi' , 'i^ushchego' , 'i^ushchogo' , 'i^ushchemu' , 'i^ushchomu' , 'i^ushchikh' , 'i^ushchykh' , 'shchi^ui^u' , 'shchi^ai^a' , 'i^ushchee' , 'i^ushchie' , 'i^ushchye' , 'i^ushchoe' , 'i^ushchei`' , 'i^ushchii`' , 'i^ushchyi`' , 'i^ushchoi`' , 'i^ushchem' , 'i^ushchim' , 'i^ushchym' , 'i^ushchom' , 'vshi^ui^u' , 'vshi^ai^a' , 'shchui^u' , 'shchai^a' , 'shchoi^u' , 'shchei^u' , 'emi^ui^u' , 'emi^ai^a' , 'nni^ui^u' , 'nni^ai^a' , 'shchimi' , 'shchymi' , 'shchego' , 'shchogo' , 'shchemu' , 'shchomu' , 'shchikh' , 'shchykh' , 'vshui^u' , 'vshai^a' , 'vshoi^u' , 'vshei^u' , 'shchee' , 'shchie' , 'shchye' , 'shchoe' , 'shchei`' , 'shchii`' , 'shchyi`' , 'shchoi`' , 'shchem' , 'shchim' , 'shchym' , 'shchom' , 'vshimi' , 'vshymi' , 'vshego' , 'vshogo' , 'vshemu' , 'vshomu' , 'vshikh' , 'vshykh' , 'emui^u' , 'emai^a' , 'emoi^u' , 'emei^u' , 'nnui^u' , 'nnai^a' , 'nnoi^u' , 'nnei^u' , 'vshee' , 'vshie' , 'vshye' , 'vshoe' , 'vshei`' , 'vshii`' , 'vshyi`' , 'vshoi`' , 'vshem' , 'vshim' , 'vshym' , 'vshom' , 'emimi' , 'emymi' , 'emego' , 'emogo' , 'ememu' , 'emomu' , 'emikh' , 'emykh' , 'nnimi' , 'nnymi' , 'nnego' , 'nnogo' , 'nnemu' , 'nnomu' , 'nnikh' , 'nnykh' , 'emee' , 'emie' , 'emye' , 'emoe' , 'emei`' , 'emii`' , 'emyi`' , 'emoi`' , 'emem' , 'emim' , 'emym' , 'emom' , 'nnee' , 'nnie' , 'nnye' , 'nnoe' , 'nnei`' , 'nnii`' , 'nnyi`' , 'nnoi`' , 'nnem' , 'nnim' , 'nnym' , 'nnom' ) : if ( rv [ - len ( suffix ) - 3 : - len ( suffix ) ] == "i^a" or rv [ - len ( suffix ) - 1 : - len ( suffix ) ] == "a" ) : word = word [ : - len ( suffix ) ] r2 = r2 [ : - len ( suffix ) ] rv = rv [ : - len ( suffix ) ] adjectival_removed = True break else : word = word [ : - len ( suffix ) ] r2 = r2 [ : - len ( suffix ) ] rv = rv [ : - len ( suffix ) ] adjectival_removed = True break if not adjectival_removed : for suffix in self . __verb_suffixes : if rv . endswith ( suffix ) : if suffix in ( "la" , "na" , "ete" , "i`te" , "li" , "i`" , "l" , "em" , "n" , "lo" , "no" , "et" , "i^ut" , "ny" , "t'" , "esh'" , "nno" ) : if ( rv [ - len ( suffix ) - 3 : - len ( suffix ) ] == "i^a" or rv [ - len ( suffix ) - 1 : - len ( suffix ) ] == "a" ) : word = word [ : - len ( suffix ) ] r2 = r2 [ : - len ( suffix ) ] rv = rv [ : - len ( suffix ) ] verb_removed = True break else : word = word [ : - len ( suffix ) ] r2 = r2 [ : - len ( suffix ) ] rv = rv [ : - len ( suffix ) ] verb_removed = True break if not adjectival_removed and not verb_removed : for suffix in self . __noun_suffixes : if rv . endswith ( suffix ) : word = word [ : - len ( suffix ) ] r2 = r2 [ : - len ( suffix ) ] rv = rv [ : - len ( suffix ) ] break # Step 2 if rv . endswith ( "i" ) : word = word [ : - 1 ] r2 = r2 [ : - 1 ] # Step 3 for suffix in self . __derivational_suffixes : if r2 . endswith ( suffix ) : word = word [ : - len ( suffix ) ] break # Step 4 if word . endswith ( "nn" ) : word = word [ : - 1 ] undouble_success = True if not undouble_success : for suffix in self . __superlative_suffixes : if word . endswith ( suffix ) : word = word [ : - len ( suffix ) ] superlative_removed = True break if word . endswith ( "nn" ) : word = word [ : - 1 ] if not undouble_success and not superlative_removed : if word . endswith ( "'" ) : word = word [ : - 1 ] if chr_exceeded : word = self . __roman_to_cyrillic ( word ) return word