(word, pos=NOUN, custom={})
| 159 | #### SINGULARIZE ################################################################################### |
| 160 | |
| 161 | def 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 |
no outgoing calls
no test coverage detected
searching dependent graphs…