def stem(self, word, alternate_vowels=False):
<EOL>word = normalize('<STR_LIT>', word.lower())<EOL>word = word.replace('<STR_LIT>', '<STR_LIT>')<EOL>if len(word) > <NUM_LIT:2>:<EOL><INDENT>for i in range(<NUM_LIT:2>, len(word)):<EOL><INDENT>if word[i] in self._vowels and word[i - <NUM_LIT:2>] in self._vowels:<EOL><INDENT>if word[i - <NUM_LIT:1>] == '<STR_LIT:u>':<EOL><INDENT>word = word[: i - <NUM_LIT:1>] + '<STR_LIT>' + word[i:]<EOL><DEDENT>elif word[i - <NUM_LIT:1>] == '<STR_LIT:y>':<EOL><INDENT>word = word[: i - <NUM_LIT:1>] + '<STR_LIT:Y>' + word[i:]<EOL><DEDENT><DEDENT><DEDENT><DEDENT>if alternate_vowels:<EOL><INDENT>word = word.replace('<STR_LIT>', '<STR_LIT>')<EOL>word = word.replace('<STR_LIT>', '<STR_LIT>')<EOL>word = word.replace('<STR_LIT>', '<STR_LIT>')<EOL>word = word.replace('<STR_LIT>', '<STR_LIT>')<EOL>word = word.replace('<STR_LIT>', '<STR_LIT>')<EOL><DEDENT>r1_start = max(<NUM_LIT:3>, self._sb_r1(word))<EOL>r2_start = self._sb_r2(word)<EOL>niss_flag = False<EOL>if word[-<NUM_LIT:3>:] == '<STR_LIT>':<EOL><INDENT>if len(word[r1_start:]) >= <NUM_LIT:3>:<EOL><INDENT>word = word[:-<NUM_LIT:3>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:2>:] == '<STR_LIT>':<EOL><INDENT>if len(word[r1_start:]) >= <NUM_LIT:2>:<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:2>:] == '<STR_LIT>':<EOL><INDENT>if len(word[r1_start:]) >= <NUM_LIT:2>:<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:2>:] == '<STR_LIT>':<EOL><INDENT>if len(word[r1_start:]) >= <NUM_LIT:2>:<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL>niss_flag = True<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:2>:] == '<STR_LIT>':<EOL><INDENT>if len(word[r1_start:]) >= <NUM_LIT:2>:<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL>niss_flag = True<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:1>:] == '<STR_LIT:e>':<EOL><INDENT>if len(word[r1_start:]) >= <NUM_LIT:1>:<EOL><INDENT>word = word[:-<NUM_LIT:1>]<EOL>niss_flag = True<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:1>:] == '<STR_LIT:s>':<EOL><INDENT>if (<EOL>len(word[r1_start:]) >= <NUM_LIT:1><EOL>and len(word) >= <NUM_LIT:2><EOL>and word[-<NUM_LIT:2>] in self._s_endings<EOL>):<EOL><INDENT>word = word[:-<NUM_LIT:1>]<EOL><DEDENT><DEDENT>if niss_flag and word[-<NUM_LIT:4>:] == '<STR_LIT>':<EOL><INDENT>word = word[:-<NUM_LIT:1>]<EOL><DEDENT>if word[-<NUM_LIT:3>:] == '<STR_LIT>':<EOL><INDENT>if len(word[r1_start:]) >= <NUM_LIT:3>:<EOL><INDENT>word = word[:-<NUM_LIT:3>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:2>:] == '<STR_LIT>':<EOL><INDENT>if len(word[r1_start:]) >= <NUM_LIT:2>:<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:2>:] == '<STR_LIT>':<EOL><INDENT>if len(word[r1_start:]) >= <NUM_LIT:2>:<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:2>:] == '<STR_LIT>':<EOL><INDENT>if (<EOL>len(word[r1_start:]) >= <NUM_LIT:2><EOL>and len(word) >= <NUM_LIT:6><EOL>and word[-<NUM_LIT:3>] in self._st_endings<EOL>):<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT><DEDENT>if word[-<NUM_LIT:4>:] == '<STR_LIT>':<EOL><INDENT>if len(word[r2_start:]) >= <NUM_LIT:4> and word[-<NUM_LIT:5>] != '<STR_LIT:e>':<EOL><INDENT>word = word[:-<NUM_LIT:4>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:4>:] in {'<STR_LIT>', '<STR_LIT>'}:<EOL><INDENT>if len(word[r2_start:]) >= <NUM_LIT:4>:<EOL><INDENT>word = word[:-<NUM_LIT:4>]<EOL>if word[-<NUM_LIT:2>:] in {'<STR_LIT>', '<STR_LIT>'} and len(word[r1_start:]) >= <NUM_LIT:2>:<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT><DEDENT><DEDENT>elif word[-<NUM_LIT:4>:] == '<STR_LIT>':<EOL><INDENT>if len(word[r2_start:]) >= <NUM_LIT:4>:<EOL><INDENT>word = word[:-<NUM_LIT:4>]<EOL>if word[-<NUM_LIT:4>:] == '<STR_LIT>' and len(word[r2_start:]) >= <NUM_LIT:4>:<EOL><INDENT>word = word[:-<NUM_LIT:4>]<EOL><DEDENT>elif word[-<NUM_LIT:2>:] == '<STR_LIT>' and len(word[r2_start:]) >= <NUM_LIT:2>:<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT><DEDENT><DEDENT>elif word[-<NUM_LIT:3>:] in {'<STR_LIT:end>', '<STR_LIT>'}:<EOL><INDENT>if len(word[r2_start:]) >= <NUM_LIT:3>:<EOL><INDENT>word = word[:-<NUM_LIT:3>]<EOL>if (<EOL>word[-<NUM_LIT:2>:] == '<STR_LIT>'<EOL>and len(word[r2_start:]) >= <NUM_LIT:2><EOL>and word[-<NUM_LIT:3>] != '<STR_LIT:e>'<EOL>):<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT><DEDENT><DEDENT>elif word[-<NUM_LIT:2>:] in {'<STR_LIT>', '<STR_LIT>'}:<EOL><INDENT>if len(word[r2_start:]) >= <NUM_LIT:2> and word[-<NUM_LIT:3>] != '<STR_LIT:e>':<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT><DEDENT>for i in range(<NUM_LIT:0>, len(word)):<EOL><INDENT>if word[i] == '<STR_LIT:Y>':<EOL><INDENT>word = word[:i] + '<STR_LIT:y>' + word[i + <NUM_LIT:1> :]<EOL><DEDENT>elif word[i] == '<STR_LIT>':<EOL><INDENT>word = word[:i] + '<STR_LIT:u>' + word[i + <NUM_LIT:1> :]<EOL><DEDENT><DEDENT>_umlauts = dict(zip((ord(_) for _ in '<STR_LIT>'), '<STR_LIT>'))<EOL>word = word.translate(_umlauts)<EOL>return word<EOL>
Return Snowball German stem.

        Parameters
        ----------
        word : str
            The word to stem
        alternate_vowels : bool
            Composes ae as ä, oe as ö, and ue as ü before running the algorithm

        Returns
        -------
        str
            Word stem

        Examples
        --------
        >>> stmr = SnowballGerman()
        >>> stmr.stem('lesen')
        'les'
        >>> stmr.stem('graues')
        'grau'
        >>> stmr.stem('buchstabieren')
        'buchstabi'