pattern/text/es/inflect.py
def find_lemma(self, verb):
        """ Returns the base form of the given inflected verb, using a rule-based approach.
        """
        # Spanish has 12,000+ verbs, ending in -ar (85%), -er (8%), -ir (7%).
        # Over 65% of -ar verbs (6500+) have a regular inflection.
        v = verb.lower()
        # Probably ends in -ir if preceding vowel in stem is -i.
        er_ir = lambda b: (len(b) > 2 and b[-2] == "i") and b+"ir" or b+"er"
        # Probably infinitive if ends in -ar, -er or -ir.
        if v.endswith(("ar", "er", "ir")):
            return v
        # Ruleset for irregular inflections adds 10% accuracy.
        for a, b in verb_irregular_inflections:
            if v.endswith(a):
                return v[:-len(a)] + b
        # reconozco => reconocer
        v = v.replace(u"zco", "ce")
        # reconozcamos => reconocer
        v = v.replace(u"zca", "ce")
        # reconozcáis => reconocer
        v = v.replace(u"zcá", "ce")
        # saldrár => saler
        if "ldr" in v: 
            return v[:v.index("ldr")+1] + "er"
        # compondrán => componer
        if "ndr" in v: 
            return v[:v.index("ndr")+1] + "er"
        # Many verbs end in -ar and have a regular inflection:
        for x in ((
          u"ando", u"ado", u"ad",                                # participle
          u"aré", u"arás", u"ará", u"aremos", u"aréis", u"arán", # future
          u"aría", u"arías", u"aríamos", u"aríais", u"arían",    # conditional
          u"aba", u"abas", u"ábamos", u"abais", u"aban",         # past imperfective
          u"é", u"aste", u"ó", u"asteis", u"aron",               # past perfective
          u"ara", u"aras", u"áramos", u"arais", u"aran")):       # past subjunctive
            if v.endswith(x):
                return v[:-len(x)] + "ar"
        # Many verbs end in -er and have a regular inflection:
        for x in ((
          u"iendo", u"ido", u"ed",                               # participle
          u"eré", u"erás", u"erá", u"eremos", u"eréis", u"erán", # future
          u"ería", u"erías", u"eríamos", u"eríais", u"erían",    # conditional
          u"ía", u"ías", u"íamos", u"íais", u"ían",              # past imperfective
          u"í", "iste", u"ió", "imos", "isteis", "ieron",        # past perfective
          u"era", u"eras", u"éramos", u"erais", u"eran")):       # past subjunctive
            if v.endswith(x):
                return er_ir(v[:-len(x)])
        # Many verbs end in -ir and have a regular inflection:
        for x in ((
          u"iré", u"irás", u"irá", u"iremos", u"iréis", u"irán", # future
          u"iría", u"irías", u"iríamos", u"iríais", u"irían")):  # past subjunctive
            if v.endswith(x):
                return v[:-len(x)] + "ir"
        # Present 1sg -o: yo hablo, como, vivo => hablar, comer, vivir.
        if v.endswith("o"):
            return v[:-1] + "ar"
        # Present 2sg, 3sg and 3pl: tú hablas.
        if v.endswith(("as", "a", "an")):
            return v.rstrip("sn")[:-1] + "ar"
        # Present 2sg, 3sg and 3pl: tú comes, tú vives.
        if v.endswith(("es", "e", "en")):
            return er_ir(v.rstrip("sn")[:-1])
        # Present 1pl and 2pl: nosotros hablamos.
        for i, x in enumerate((
          ("amos", u"áis"), 
          ("emos", u"éis"), 
          ("imos", u"ís"))):
            for x in x:
                if v.endswith(x):
                    return v[:-len(x)] + ("ar", "er", "ir")[i]
        return v
 Returns the base form of the given inflected verb, using a rule-based approach.
        
Returns the base form of the given inflected verb, using a rule-based approach.
Returns the base form of the given inflected verb using a rule - based approach .
def find_lemma(self, verb):
        v = verb.lower()
        er_ir = lambda b: (len(b) > 2 and b[-2] == "i") and b+"ir" or b+"er"
        if v.endswith(("ar", "er", "ir")):
            return v
        for a, b in verb_irregular_inflections:
            if v.endswith(a):
                return v[:-len(a)] + b
        v = v.replace(u"zco", "ce")
        v = v.replace(u"zca", "ce")
        v = v.replace(u"zcá", "ce")
        if "ldr" in v: 
            return v[:v.index("ldr")+1] + "er"
        if "ndr" in v: 
            return v[:v.index("ndr")+1] + "er"
        for x in ((
          u"ando", u"ado", u"ad",                                
          u"aré", u"arás", u"ará", u"aremos", u"aréis", u"arán", # fut
          u"aría", u"arías", u"aríamos", u"aríais", u"arían",    # con
          u"aba", u"abas", u"ábamos", u"abais", u"aban",         #
          u"é", u"aste", u"ó", u"asteis", u"aron",               # 
          u"ara", u"aras", u"áramos", u"arais", u"aran")):       #
            if v.endswith(x):
                return v[:-len(x)] + "ar"
        for x in ((
          u"iendo", u"ido", u"ed",                               
          u"eré", u"erás", u"erá", u"eremos", u"eréis", u"erán", # fut
          u"ería", u"erías", u"eríamos", u"eríais", u"erían",    # con
          u"ía", u"ías", u"íamos", u"íais", u"ían",              #
          u"í", "iste", u"ió", "imos", "isteis", "ieron",        # 
          u"era", u"eras", u"éramos", u"erais", u"eran")):       #
            if v.endswith(x):
                return er_ir(v[:-len(x)])
        for x in ((
          u"iré", u"irás", u"irá", u"iremos", u"iréis", u"irán", # fut
          u"iría", u"irías", u"iríamos", u"iríais", u"irían")):  #
            if v.endswith(x):
                return v[:-len(x)] + "ir"
        if v.endswith("o"):
            return v[:-1] + "ar"
        if v.endswith(("as", "a", "an")):
            return v.rstrip("sn")[:-1] + "ar"
        if v.endswith(("es", "e", "en")):
            return er_ir(v.rstrip("sn")[:-1])
        for i, x in enumerate((
          ("amos", u"áis"), 
          ("emos", u"éis"), 
          ("imos", u"ís"))):
            for x in x:
                if v.endswith(x):
                    return v[:-len(x)] + ("ar", "er", "ir")[i]
        return v
def find_lemma ( self , verb ) : v = verb . lower ( ) er_ir = lambda b : ( len ( b ) > 2 and b [ - 2 ] == "i" ) and b + "ir" or b + "er" if v . endswith ( ( "ar" , "er" , "ir" ) ) : return v for a , b in verb_irregular_inflections : if v . endswith ( a ) : return v [ : - len ( a ) ] + b v = v . replace ( u"zco" , "ce" ) v = v . replace ( u"zca" , "ce" ) v = v . replace ( u"zcá", ce") if "ldr" in v : return v [ : v . index ( "ldr" ) + 1 ] + "er" if "ndr" in v : return v [ : v . index ( "ndr" ) + 1 ] + "er" for x in ( ( u"ando" , u"ado" , u"ad" , u"aré", "arás",  u ará", u " remos", u " réis", u" a án", # f u u"aría", "arías",  u aríamos", u " ríais", u" a ían",     # u"aba" , u"abas" , u"ábamos", "abais", "aban", u"é", "aste", "ó",  u asteis",  u aron",  u"ara" , u"aras" , u"áramos", "arais", "aran") ) : if v . endswith ( x ) : return v [ : - len ( x ) ] + "ar" for x in ( ( u"iendo" , u"ido" , u"ed" , u"eré", "erás",  u erá", u " remos", u " réis", u" e án", # f u u"ería", "erías",  u eríamos", u " ríais", u" e ían",     # u"ía", "ías",  u íamos", u " ais", u" í n",     u"í", iste", "ió",  " mos",  " steis",  " eron",  u"era" , u"eras" , u"éramos", "erais", "eran") ) : if v . endswith ( x ) : return er_ir ( v [ : - len ( x ) ] ) for x in ( ( u"iré", "irás",  u irá", u " remos", u " réis", u" i án", # f u u"iría", "irías",  u iríamos", u " ríais", u" i ían")):   # p if v . endswith ( x ) : return v [ : - len ( x ) ] + "ir" if v . endswith ( "o" ) : return v [ : - 1 ] + "ar" if v . endswith ( ( "as" , "a" , "an" ) ) : return v . rstrip ( "sn" ) [ : - 1 ] + "ar" if v . endswith ( ( "es" , "e" , "en" ) ) : return er_ir ( v . rstrip ( "sn" ) [ : - 1 ] ) for i , x in enumerate ( ( ( "amos" , u"áis") , ( "emos" , u"éis") , ( "imos" , u"ís") ) ) : for x in x : if v . endswith ( x ) : return v [ : - len ( x ) ] + ( "ar" , "er" , "ir" ) [ i ] return v
Returns the base form of the given inflected verb, using a rule-based approach.
Returns the base form of the given inflected verb using a rule - based approach .
""" Returns the base form of the given inflected verb, using a rule-based approach.
        """ # Spanish has 12,000+ verbs, ending in -ar (85%), -er (8%), -ir (7%). # Over 65% of -ar verbs (6500+) have a regular inflection. # Probably ends in -ir if preceding vowel in stem is -i. # Probably infinitive if ends in -ar, -er or -ir. # Ruleset for irregular inflections adds 10% accuracy. # reconozco => reconocer # reconozcamos => reconocer # reconozcáis => reconocer # saldrár => saler # compondrán => componer # Many verbs end in -ar and have a regular inflection: # participle ure ditional  past imperfective past perfective  past subjunctive # Many verbs end in -er and have a regular inflection: # participle ure ditional t imperfective past perfective  past subjunctive # Many verbs end in -ir and have a regular inflection: ure t subjunctive # Present 1sg -o: yo hablo, como, vivo => hablar, comer, vivir. # Present 2sg, 3sg and 3pl: tú hablas. # Present 2sg, 3sg and 3pl: tú comes, tú vives. # Present 1pl and 2pl: nosotros hablamos.
self
verb