'Stem a Spanish word and return the stemmed form.
:param word: The word that is stemmed.
:type word: str or unicode
:return: The stemmed form.
:rtype: unicode'

def stem(self, word):

    word = word.lower()
    if (word in self.stopwords):
        return word
    step1_success = False
    (r1, r2) = self._r1r2_standard(word, self.__vowels)
    rv = self._rv_standard(word, self.__vowels)
    for suffix in self.__step0_suffixes:
        if (not (word.endswith(suffix) and rv.endswith(suffix))):
            continue
        if (rv[:(- len(suffix))].endswith((u'ando', u'\xe1ndo', u'ar', u'\xe1r', u'er', u'\xe9r', u'iendo', u'i\xe9ndo', u'ir', u'\xedr')) or (rv[:(- len(suffix))].endswith(u'yendo') and word[:(- len(suffix))].endswith(u'uyendo'))):
            word = self.__replace_accented(word[:(- len(suffix))])
            r1 = self.__replace_accented(r1[:(- len(suffix))])
            r2 = self.__replace_accented(r2[:(- len(suffix))])
            rv = self.__replace_accented(rv[:(- len(suffix))])
        break
    for suffix in self.__step1_suffixes:
        if (not word.endswith(suffix)):
            continue
        if ((suffix == u'amente') and r1.endswith(suffix)):
            step1_success = True
            word = word[:(-6)]
            r2 = r2[:(-6)]
            rv = rv[:(-6)]
            if r2.endswith(u'iv'):
                word = word[:(-2)]
                r2 = r2[:(-2)]
                rv = rv[:(-2)]
                if r2.endswith(u'at'):
                    word = word[:(-2)]
                    rv = rv[:(-2)]
            elif r2.endswith((u'os', u'ic', u'ad')):
                word = word[:(-2)]
                rv = rv[:(-2)]
        elif r2.endswith(suffix):
            step1_success = True
            if (suffix in (u'adora', u'ador', u'aci\xf3n', u'adoras', u'adores', u'aciones', u'ante', u'antes', u'ancia', u'ancias')):
                word = word[:(- len(suffix))]
                r2 = r2[:(- len(suffix))]
                rv = rv[:(- len(suffix))]
                if r2.endswith(u'ic'):
                    word = word[:(-2)]
                    rv = rv[:(-2)]
            elif (suffix in (u'log\xeda', u'log\xedas')):
                word = suffix_replace(word, suffix, u'log')
                rv = suffix_replace(rv, suffix, u'log')
            elif (suffix in (u'uci\xf3n', u'uciones')):
                word = suffix_replace(word, suffix, u'u')
                rv = suffix_replace(rv, suffix, u'u')
            elif (suffix in (u'encia', u'encias')):
                word = suffix_replace(word, suffix, u'ente')
                rv = suffix_replace(rv, suffix, u'ente')
            elif (suffix == u'mente'):
                word = word[:(- len(suffix))]
                r2 = r2[:(- len(suffix))]
                rv = rv[:(- len(suffix))]
                if r2.endswith((u'ante', u'able', u'ible')):
                    word = word[:(-4)]
                    rv = rv[:(-4)]
            elif (suffix in (u'idad', u'idades')):
                word = word[:(- len(suffix))]
                r2 = r2[:(- len(suffix))]
                rv = rv[:(- len(suffix))]
                for pre_suff in (u'abil', u'ic', u'iv'):
                    if r2.endswith(pre_suff):
                        word = word[:(- len(pre_suff))]
                        rv = rv[:(- len(pre_suff))]
            elif (suffix in (u'ivo', u'iva', u'ivos', u'ivas')):
                word = word[:(- len(suffix))]
                r2 = r2[:(- len(suffix))]
                rv = rv[:(- len(suffix))]
                if r2.endswith(u'at'):
                    word = word[:(-2)]
                    rv = rv[:(-2)]
            else:
                word = word[:(- len(suffix))]
                rv = rv[:(- len(suffix))]
        break
    if (not step1_success):
        for suffix in self.__step2a_suffixes:
            if (rv.endswith(suffix) and (word[((- len(suffix)) - 1):(- len(suffix))] == u'u')):
                word = word[:(- len(suffix))]
                rv = rv[:(- len(suffix))]
                break
        for suffix in self.__step2b_suffixes:
            if rv.endswith(suffix):
                word = word[:(- len(suffix))]
                rv = rv[:(- len(suffix))]
                if (suffix in (u'en', u'es', u'\xe9is', u'emos')):
                    if word.endswith(u'gu'):
                        word = word[:(-1)]
                    if rv.endswith(u'gu'):
                        rv = rv[:(-1)]
                break
    for suffix in self.__step3_suffixes:
        if rv.endswith(suffix):
            word = word[:(- len(suffix))]
            if (suffix in (u'e', u'\xe9')):
                rv = rv[:(- len(suffix))]
                if ((word[(-2):] == u'gu') and rv.endswith(u'u')):
                    word = word[:(-1)]
            break
    word = self.__replace_accented(word)
    return word
