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

        r1 = self.__r1_hungarian(word, self.__vowels, self.__digraphs)

        # STEP 1: Remove instrumental case
        if r1.endswith(self.__step1_suffixes):
            for double_cons in self.__double_consonants:
                if word[-2 - len(double_cons):-2] == double_cons:
                    word = "".join((word[:-4], word[-3]))

                    if r1[-2 - len(double_cons):-2] == double_cons:
                        r1 = "".join((r1[:-4], r1[-3]))
                    break

        # STEP 2: Remove frequent cases
        for suffix in self.__step2_suffixes:
            if word.endswith(suffix):
                if r1.endswith(suffix):
                    word = word[:-len(suffix)]
                    r1 = r1[:-len(suffix)]

                    if r1.endswith(u("\xE1")):
                        word = "".join((word[:-1], "a"))
                        r1 = "".join((r1[:-1], "a"))

                    elif r1.endswith(u("\xE9")):
                        word = "".join((word[:-1], "e"))
                        r1 = "".join((r1[:-1], "e"))
                break

        # STEP 3: Remove special cases
        for suffix in self.__step3_suffixes:
            if r1.endswith(suffix):
                if suffix == u("\xE9n"):
                    word = "".join((word[:-2], "e"))
                    r1 = "".join((r1[:-2], "e"))
                else:
                    word = "".join((word[:-len(suffix)], "a"))
                    r1 = "".join((r1[:-len(suffix)], "a"))
                break

        # STEP 4: Remove other cases
        for suffix in self.__step4_suffixes:
            if r1.endswith(suffix):
                if suffix == u("\xE1stul"):
                    word = "".join((word[:-5], "a"))
                    r1 = "".join((r1[:-5], "a"))

                elif suffix == u("\xE9st\xFCl"):
                    word = "".join((word[:-5], "e"))
                    r1 = "".join((r1[:-5], "e"))
                else:
                    word = word[:-len(suffix)]
                    r1 = r1[:-len(suffix)]
                break

        # STEP 5: Remove factive case
        for suffix in self.__step5_suffixes:
            if r1.endswith(suffix):
                for double_cons in self.__double_consonants:
                    if word[-1 - len(double_cons):-1] == double_cons:
                        word = "".join((word[:-3], word[-2]))

                        if r1[-1 - len(double_cons):-1] == double_cons:
                            r1 = "".join((r1[:-3], r1[-2]))
                        break

        # STEP 6: Remove owned
        for suffix in self.__step6_suffixes:
            if r1.endswith(suffix):
                if suffix in (u("\xE1k\xE9"), u("\xE1\xE9i")):
                    word = "".join((word[:-3], "a"))
                    r1 = "".join((r1[:-3], "a"))

                elif suffix in (u("\xE9k\xE9"), u("\xE9\xE9i"),
                                u("\xE9\xE9")):
                    word = "".join((word[:-len(suffix)], "e"))
                    r1 = "".join((r1[:-len(suffix)], "e"))
                else:
                    word = word[:-len(suffix)]
                    r1 = r1[:-len(suffix)]
                break

        # STEP 7: Remove singular owner suffixes
        for suffix in self.__step7_suffixes:
            if word.endswith(suffix):
                if r1.endswith(suffix):
                    if suffix in (u("\xE1nk"), u("\xE1juk"), u("\xE1m"),
                                  u("\xE1d"), u("\xE1")):
                        word = "".join((word[:-len(suffix)], "a"))
                        r1 = "".join((r1[:-len(suffix)], "a"))

                    elif suffix in (u("\xE9nk"), u("\xE9j\xFCk"),
                                    u("\xE9m"), u("\xE9d"), u("\xE9")):
                        word = "".join((word[:-len(suffix)], "e"))
                        r1 = "".join((r1[:-len(suffix)], "e"))
                    else:
                        word = word[:-len(suffix)]
                        r1 = r1[:-len(suffix)]
                break

        # STEP 8: Remove plural owner suffixes
        for suffix in self.__step8_suffixes:
            if word.endswith(suffix):
                if r1.endswith(suffix):
                    if suffix in (u("\xE1im"), u("\xE1id"), u("\xE1i"),
                                  u("\xE1ink"), u("\xE1itok"), u("\xE1ik")):
                        word = "".join((word[:-len(suffix)], "a"))
                        r1 = "".join((r1[:-len(suffix)], "a"))

                    elif suffix in (u("\xE9im"), u("\xE9id"), u("\xE9i"),
                                    u("\xE9ink"), u("\xE9itek"), u("\xE9ik")):
                        word = "".join((word[:-len(suffix)], "e"))
                        r1 = "".join((r1[:-len(suffix)], "e"))
                    else:
                        word = word[:-len(suffix)]
                        r1 = r1[:-len(suffix)]
                break

        # STEP 9: Remove plural suffixes
        for suffix in self.__step9_suffixes:
            if word.endswith(suffix):
                if r1.endswith(suffix):
                    if suffix == u("\xE1k"):
                        word = "".join((word[:-2], "a"))
                    elif suffix == u("\xE9k"):
                        word = "".join((word[:-2], "e"))
                    else:
                        word = word[:-len(suffix)]
                break

        return word
def stem ( self , word ) : word = word . lower ( ) r1 = self . __r1_hungarian ( word , self . __vowels , self . __digraphs ) # STEP 1: Remove instrumental case if r1 . endswith ( self . __step1_suffixes ) : for double_cons in self . __double_consonants : if word [ - 2 - len ( double_cons ) : - 2 ] == double_cons : word = "" . join ( ( word [ : - 4 ] , word [ - 3 ] ) ) if r1 [ - 2 - len ( double_cons ) : - 2 ] == double_cons : r1 = "" . join ( ( r1 [ : - 4 ] , r1 [ - 3 ] ) ) break # STEP 2: Remove frequent cases for suffix in self . __step2_suffixes : if word . endswith ( suffix ) : if r1 . endswith ( suffix ) : word = word [ : - len ( suffix ) ] r1 = r1 [ : - len ( suffix ) ] if r1 . endswith ( u ( "\xE1" ) ) : word = "" . join ( ( word [ : - 1 ] , "a" ) ) r1 = "" . join ( ( r1 [ : - 1 ] , "a" ) ) elif r1 . endswith ( u ( "\xE9" ) ) : word = "" . join ( ( word [ : - 1 ] , "e" ) ) r1 = "" . join ( ( r1 [ : - 1 ] , "e" ) ) break # STEP 3: Remove special cases for suffix in self . __step3_suffixes : if r1 . endswith ( suffix ) : if suffix == u ( "\xE9n" ) : word = "" . join ( ( word [ : - 2 ] , "e" ) ) r1 = "" . join ( ( r1 [ : - 2 ] , "e" ) ) else : word = "" . join ( ( word [ : - len ( suffix ) ] , "a" ) ) r1 = "" . join ( ( r1 [ : - len ( suffix ) ] , "a" ) ) break # STEP 4: Remove other cases for suffix in self . __step4_suffixes : if r1 . endswith ( suffix ) : if suffix == u ( "\xE1stul" ) : word = "" . join ( ( word [ : - 5 ] , "a" ) ) r1 = "" . join ( ( r1 [ : - 5 ] , "a" ) ) elif suffix == u ( "\xE9st\xFCl" ) : word = "" . join ( ( word [ : - 5 ] , "e" ) ) r1 = "" . join ( ( r1 [ : - 5 ] , "e" ) ) else : word = word [ : - len ( suffix ) ] r1 = r1 [ : - len ( suffix ) ] break # STEP 5: Remove factive case for suffix in self . __step5_suffixes : if r1 . endswith ( suffix ) : for double_cons in self . __double_consonants : if word [ - 1 - len ( double_cons ) : - 1 ] == double_cons : word = "" . join ( ( word [ : - 3 ] , word [ - 2 ] ) ) if r1 [ - 1 - len ( double_cons ) : - 1 ] == double_cons : r1 = "" . join ( ( r1 [ : - 3 ] , r1 [ - 2 ] ) ) break # STEP 6: Remove owned for suffix in self . __step6_suffixes : if r1 . endswith ( suffix ) : if suffix in ( u ( "\xE1k\xE9" ) , u ( "\xE1\xE9i" ) ) : word = "" . join ( ( word [ : - 3 ] , "a" ) ) r1 = "" . join ( ( r1 [ : - 3 ] , "a" ) ) elif suffix in ( u ( "\xE9k\xE9" ) , u ( "\xE9\xE9i" ) , u ( "\xE9\xE9" ) ) : word = "" . join ( ( word [ : - len ( suffix ) ] , "e" ) ) r1 = "" . join ( ( r1 [ : - len ( suffix ) ] , "e" ) ) else : word = word [ : - len ( suffix ) ] r1 = r1 [ : - len ( suffix ) ] break # STEP 7: Remove singular owner suffixes for suffix in self . __step7_suffixes : if word . endswith ( suffix ) : if r1 . endswith ( suffix ) : if suffix in ( u ( "\xE1nk" ) , u ( "\xE1juk" ) , u ( "\xE1m" ) , u ( "\xE1d" ) , u ( "\xE1" ) ) : word = "" . join ( ( word [ : - len ( suffix ) ] , "a" ) ) r1 = "" . join ( ( r1 [ : - len ( suffix ) ] , "a" ) ) elif suffix in ( u ( "\xE9nk" ) , u ( "\xE9j\xFCk" ) , u ( "\xE9m" ) , u ( "\xE9d" ) , u ( "\xE9" ) ) : word = "" . join ( ( word [ : - len ( suffix ) ] , "e" ) ) r1 = "" . join ( ( r1 [ : - len ( suffix ) ] , "e" ) ) else : word = word [ : - len ( suffix ) ] r1 = r1 [ : - len ( suffix ) ] break # STEP 8: Remove plural owner suffixes for suffix in self . __step8_suffixes : if word . endswith ( suffix ) : if r1 . endswith ( suffix ) : if suffix in ( u ( "\xE1im" ) , u ( "\xE1id" ) , u ( "\xE1i" ) , u ( "\xE1ink" ) , u ( "\xE1itok" ) , u ( "\xE1ik" ) ) : word = "" . join ( ( word [ : - len ( suffix ) ] , "a" ) ) r1 = "" . join ( ( r1 [ : - len ( suffix ) ] , "a" ) ) elif suffix in ( u ( "\xE9im" ) , u ( "\xE9id" ) , u ( "\xE9i" ) , u ( "\xE9ink" ) , u ( "\xE9itek" ) , u ( "\xE9ik" ) ) : word = "" . join ( ( word [ : - len ( suffix ) ] , "e" ) ) r1 = "" . join ( ( r1 [ : - len ( suffix ) ] , "e" ) ) else : word = word [ : - len ( suffix ) ] r1 = r1 [ : - len ( suffix ) ] break # STEP 9: Remove plural suffixes for suffix in self . __step9_suffixes : if word . endswith ( suffix ) : if r1 . endswith ( suffix ) : if suffix == u ( "\xE1k" ) : word = "" . join ( ( word [ : - 2 ] , "a" ) ) elif suffix == u ( "\xE9k" ) : word = "" . join ( ( word [ : - 2 ] , "e" ) ) else : word = word [ : - len ( suffix ) ] break return word