class_docstr: Spanish rule-based lemmatizer with morph-based rule selection.
class_docstr_tok: ["Spanish","rule-based","lemmatizer","with","morph-based","rule","selection","."]
docstr: Lemmatize a verb.
  
  word (str): The word to lemmatize.
  features (List[str]): The morphological features as a list of Feat=Val
      pairs.
  index (List[str]): The POS-specific lookup list.
  
  RETURNS (List[str]): The list of lemmas.
docstr_tok: ["Lemmatize","a","verb",".","word","(","str",")",":","The","word","to","lemmatize",".","features","(","List","[","str","]",")",":","The","morphological","features","as","a","list","of","Feat=Val","pairs",".","index","(","List","[","str","]",")",":","The","POS-specific","lookup","list",".","RETURNS","(","List","[","str","]",")",":","The","list","of","lemmas","."]
code: def lemmatize_verb(
      self,
      word: str,
      features: List[str],
      rule: Optional[str],
      index: List[str],
  ) -> List[str]:
      """
      Lemmatize a verb.
  
      word (str): The word to lemmatize.
      features (List[str]): The morphological features as a list of Feat=Val
          pairs.
      index (List[str]): The POS-specific lookup list.
  
      RETURNS (List[str]): The list of lemmas.
      """
      # Exceptions for verb+pronoun(s)
      if "PronType=Prs" in features:
          return self.lemmatize_verb_pron(word, features, rule, index)
  
      # Initialize empty lists for the generated lemmas
      possible_lemmas = []
      selected_lemmas = []
  
      # Apply lemmatization rules
      rule = str(rule or "")
      for old, new in self.lookups.get_table("lemma_rules").get(
          rule, []
      ):
          possible_lemma = re.sub(old + "$", new, word)
          if possible_lemma != word:
              possible_lemmas.append(possible_lemma)
  
      for lemma in possible_lemmas:
          if lemma in index:
              selected_lemmas.append(lemma)
      if len(selected_lemmas) == 0:
          # If none of the possible lemmas are in the lookup list,
          # apply vocalic alternation rules and search in the lookup list
          # again
          for lemma in possible_lemmas:
              for old, new in self.lookups.get_table("lemma_rules").get(
                  "voc_alt_1", []
              ):
                  if old in lemma:
                      for i, char in enumerate(lemma):
                          if char == old:
                              voc_alt_lemma = (
                                  lemma[:i] + new + lemma[i + 1 :]
                              )
                              if voc_alt_lemma in index:
                                  selected_lemmas.append(voc_alt_lemma)
              for old, new in self.lookups.get_table("lemma_rules").get(
                  "voc_alt_2", []
              ):
                  if old in lemma:
                      voc_alt_lemma = lemma.replace(old, new, 1)
                      if voc_alt_lemma in index:
                          selected_lemmas.append(voc_alt_lemma)
      # Additional rule for verbs that lose the accent mark when lemmatized,
      # e.g., amplían -> ampliar
      additional_lemmas = []
      for possible_lemma in possible_lemmas:
          for old, new in self.lookups.get_table("lemma_rules").get(
              "accents", []
          ):
              additional_lemmas.append(re.sub(old, new, possible_lemma))
      possible_lemmas.extend(additional_lemmas)
  
      # If one or more of the created possible lemmas are in the lookup list,
      # return all of them
      if len(selected_lemmas) > 0:
          return selected_lemmas
      elif len(possible_lemmas) > 0:
          return possible_lemmas
      else:
          return [word]
  
file_path: spacy/spacy/lang/es/lemmatizer.py
imports: import re
  from typing import List, Optional, Tuple
  from ...pipeline import Lemmatizer
  from ...tokens import Token
label_desc: Use image node_id 10 for calling the SpanishLemmatizer obj's underlying member method code with example usage: obj.lemmatize_verb(word, features, rule, index) and returns: self, selected_lemmas, possible_lemmas, list