MCPcopy Index your code
hub / github.com/clips/pattern / pluralize

Function pluralize

pattern/text/it/inflect.py:161–195  ·  view source on GitHub ↗

Returns the plural of a given word.

(word, pos=NOUN, custom={})

Source from the content-addressed store, hash-verified

159}
160
161def pluralize(word, pos=NOUN, custom={}):
162 """ Returns the plural of a given word.
163 """
164 if word in custom:
165 return custom[word]
166 w = word.lower()
167 if len(w) < 3:
168 return w
169 if w in plural_irregular:
170 return plural_irregular[w]
171 # provincia => province (but: socia => socie)
172 if w.endswith(("cia", "gia")) and len(w) > 4 and not is_vowel(w[-4]):
173 return w[:-2] + "e"
174 # amica => amiche
175 if w.endswith(("ca", "ga")):
176 return w[:-2] + "he"
177 # studentessa => studentesse
178 if w.endswith("a"):
179 return w[:-1] + "e"
180 # studente => studenti
181 if w.endswith("e"):
182 return w[:-1] + "i"
183 # viaggio => viaggi (but: leggìo => leggìi)
184 if w.endswith("io"):
185 return w[:-2] + "i"
186 # abbaco => abbachi
187 if w in plural_co_chi:
188 return w[:-2] + "chi"
189 # albergo => alberghi
190 if w in plural_co_chi:
191 return w[:-2] + "ghi"
192 # amico => amici
193 if w.endswith("o"):
194 return w[:-1] + "i"
195 return w
196
197#### SINGULARIZE ###################################################################################
198

Callers

nothing calls this directly

Calls 2

lenFunction · 0.85
is_vowelFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…