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

Function singularize

pattern/text/es/inflect.py:161–197  ·  view source on GitHub ↗
(word, pos=NOUN, custom={})

Source from the content-addressed store, hash-verified

159#### SINGULARIZE ###################################################################################
160
161def singularize(word, pos=NOUN, custom={}):
162 if word in custom:
163 return custom[word]
164 w = word.lower()
165 # los gatos => el gato
166 if pos == "DT":
167 if w in ("la", "las", "los"):
168 return "el"
169 if w in ("una", "unas", "unos"):
170 return "un"
171 return w
172 # hombres => hombre
173 if w.endswith("es") and w[:-2].endswith(("br", "i", "j", "t", "zn")):
174 return w[:-1]
175 # gestiones => gestión
176 for a, b in (
177 ("anes", u"án"),
178 ("enes", u"én"),
179 ("eses", u"és"),
180 ("ines", u"ín"),
181 ("ones", u"ón"),
182 ("unes", u"ún")):
183 if w.endswith(a):
184 return w[:-4] + b
185 # hipotesis => hipothesis
186 if w.endswith(("esis", "isis", "osis")):
187 return w
188 # luces => luz
189 if w.endswith("ces"):
190 return w[:-3] + "z"
191 # hospitales => hospital
192 if w.endswith("es"):
193 return w[:-2]
194 # gatos => gato
195 if w.endswith("s"):
196 return w[:-1]
197 return w
198
199#### VERB CONJUGATION ##############################################################################
200

Callers 1

find_lemmataFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…