code: def stem(self, word):
      """
      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
  
      """
      word = word.lower()
  
      step1_success = False
  
      r1, r2 = self._r1r2_standard(word, self.__vowels)
      rv = self._rv_standard(word, self.__vowels)
  
      # STEP 0: Attached pronoun
      for suffix in self.__step0_suffixes:
          if word.endswith(suffix):
              if rv.endswith(suffix):
                  if rv[: -len(suffix)].endswith(
                      (
                          u("i\xE9ndo"),
                          u("\xE1ndo"),
                          u("\xE1r"),
                          u("\xE9r"),
                          u("\xEDr"),
                      )
                  ):
                      word = (
                          word[: -len(suffix)]
                          .replace(u("\xE1"), "a")
                          .replace(u("\xE9"), "e")
                          .replace(u("\xED"), "i")
                      )
                      r1 = (
                          r1[: -len(suffix)]
                          .replace(u("\xE1"), "a")
                          .replace(u("\xE9"), "e")
                          .replace(u("\xED"), "i")
                      )
                      r2 = (
                          r2[: -len(suffix)]
                          .replace(u("\xE1"), "a")
                          .replace(u("\xE9"), "e")
                          .replace(u("\xED"), "i")
                      )
                      rv = (
                          rv[: -len(suffix)]
                          .replace(u("\xE1"), "a")
                          .replace(u("\xE9"), "e")
                          .replace(u("\xED"), "i")
                      )
  
                  elif rv[: -len(suffix)].endswith(
                      ("ando", "iendo", "ar", "er", "ir")
                  ):
                      word = word[: -len(suffix)]
                      r1 = r1[: -len(suffix)]
                      r2 = r2[: -len(suffix)]
                      rv = rv[: -len(suffix)]
  
                  elif rv[: -len(suffix)].endswith("yendo") and word[
                      : -len(suffix)
                  ].endswith("uyendo"):
                      word = word[: -len(suffix)]
                      r1 = r1[: -len(suffix)]
                      r2 = r2[: -len(suffix)]
                      rv = rv[: -len(suffix)]
              break
  
      # STEP 1: Standard suffix removal
      for suffix in self.__step1_suffixes:
          if word.endswith(suffix):
              if suffix == "amente" and r1.endswith(suffix):
                  step1_success = True
                  word = word[:-6]
                  r2 = r2[:-6]
                  rv = rv[:-6]
  
                  if r2.endswith("iv"):
                      word = word[:-2]
                      r2 = r2[:-2]
                      rv = rv[:-2]
  
                      if r2.endswith("at"):
                          word = word[:-2]
                          rv = rv[:-2]
  
                  elif r2.endswith(("os", "ic", "ad")):
                      word = word[:-2]
                      rv = rv[:-2]
  
              elif r2.endswith(suffix):
                  step1_success = True
                  if suffix in (
                      "adora",
                      "ador",
                      u("aci\xF3n"),
                      "adoras",
                      "adores",
                      "aciones",
                      "ante",
                      "antes",
                      "ancia",
                      "ancias",
                  ):
                      word = word[: -len(suffix)]
                      r2 = r2[: -len(suffix)]
                      rv = rv[: -len(suffix)]
  
                      if r2.endswith("ic"):
                          word = word[:-2]
                          rv = rv[:-2]
  
                  elif suffix in (u("log\xEDa"), u("log\xEDas")):
                      word = word.replace(suffix, "log")
                      rv = rv.replace(suffix, "log")
  
                  elif suffix in (u("uci\xF3n"), "uciones"):
                      word = word.replace(suffix, "u")
                      rv = rv.replace(suffix, "u")
  
                  elif suffix in ("encia", "encias"):
                      word = word.replace(suffix, "ente")
                      rv = rv.replace(suffix, "ente")
  
                  elif suffix == "mente":
                      word = word[:-5]
                      r2 = r2[:-5]
                      rv = rv[:-5]
  
                      if r2.endswith(("ante", "able", "ible")):
                          word = word[:-4]
                          rv = rv[:-4]
  
                  elif suffix in ("idad", "idades"):
                      word = word[: -len(suffix)]
                      r2 = r2[: -len(suffix)]
                      rv = rv[: -len(suffix)]
  
                      for pre_suff in ("abil", "ic", "iv"):
                          if r2.endswith(pre_suff):
                              word = word[: -len(pre_suff)]
                              rv = rv[: -len(pre_suff)]
  
                  elif suffix in ("ivo", "iva", "ivos", "ivas"):
                      word = word[: -len(suffix)]
                      r2 = r2[: -len(suffix)]
                      rv = rv[: -len(suffix)]
                      if r2.endswith("at"):
                          word = word[:-2]
                          rv = rv[:-2]
                  else:
                      word = word[: -len(suffix)]
                      rv = rv[: -len(suffix)]
              break
  
      # STEP 2a: Verb suffixes beginning 'y'
      if not step1_success:
          for suffix in self.__step2a_suffixes:
              if (
                  rv.endswith(suffix)
                  and word[-len(suffix) - 1 : -len(suffix)] == "u"
              ):
                  word = word[: -len(suffix)]
                  rv = rv[: -len(suffix)]
                  break
  
          # STEP 2b: Other verb suffixes
          for suffix in self.__step2b_suffixes:
              if rv.endswith(suffix):
                  if suffix in ("en", "es", u("\xE9is"), "emos"):
                      word = word[: -len(suffix)]
                      rv = rv[: -len(suffix)]
  
                      if word.endswith("gu"):
                          word = word[:-1]
  
                      if rv.endswith("gu"):
                          rv = rv[:-1]
                  else:
                      word = word[: -len(suffix)]
                      rv = rv[: -len(suffix)]
                  break
  
      # STEP 3: Residual suffix
      for suffix in self.__step3_suffixes:
          if rv.endswith(suffix):
              if suffix in ("e", u("\xE9")):
                  word = word[: -len(suffix)]
                  rv = rv[: -len(suffix)]
  
                  if (
                      len(word) >= 2
                      and word[-2:] == "gu"
                      and len(rv) > 0
                      and rv[-1] == "u"
                  ):
                      word = word[:-1]
              else:
                  word = word[: -len(suffix)]
              break
  
      word = (
          word.replace(u("\xE1"), "a")
          .replace(u("\xE9"), "e")
          .replace(u("\xED"), "i")
          .replace(u("\xF3"), "o")
          .replace(u("\xFA"), "u")
      )
      return word
  
imports: from .bases import _StandardStemmer
  from whoosh.compat import u
label_desc: Use image node_id 1 for calling the SpanishStemmer obj's underlying member method code with example usage: obj.stem(word) and returns: word