MCPcopy Create free account
hub / github.com/clips/pattern / predicative

Function predicative

pattern/text/es/inflect.py:402–424  ·  view source on GitHub ↗

Returns the predicative adjective (lowercase). In Spanish, the attributive form is always used for descriptive adjectives: "el chico alto" => masculine, "la chica alta" => feminine. The predicative is useful for lemmatization.

(adjective)

Source from the content-addressed store, hash-verified

400#print attributive("normal", gender=PLURAL) # normales
401
402def predicative(adjective):
403 """ Returns the predicative adjective (lowercase).
404 In Spanish, the attributive form is always used for descriptive adjectives:
405 "el chico alto" => masculine,
406 "la chica alta" => feminine.
407 The predicative is useful for lemmatization.
408 """
409 w = adjective.lower()
410 # histéricos => histérico
411 if w.endswith(("os", "as")):
412 w = w[:-1]
413 # histérico => histérico
414 if w.endswith("o"):
415 return w
416 # histérica => histérico
417 if w.endswith("a"):
418 return w[:-1] + "o"
419 # horribles => horrible, humorales => humoral
420 if w.endswith("es"):
421 if len(w) >= 4 and not is_vowel(normalize(w[-3])) and not is_vowel(normalize(w[-4])):
422 return w[:-1]
423 return w[:-2]
424 return w

Callers 1

find_lemmataFunction · 0.90

Calls 3

lenFunction · 0.85
is_vowelFunction · 0.85
normalizeFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…