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

Function singularize

pattern/text/de/inflect.py:306–320  ·  view source on GitHub ↗

Returns the singular of a given word. The inflection is based on probability rather than gender and role.

(word, pos=NOUN, gender=MALE, role=SUBJECT, custom={})

Source from the content-addressed store, hash-verified

304]
305
306def singularize(word, pos=NOUN, gender=MALE, role=SUBJECT, custom={}):
307 """ Returns the singular of a given word.
308 The inflection is based on probability rather than gender and role.
309 """
310 w = word.lower().capitalize()
311 if pos == NOUN:
312 for a, b in singular_inflections:
313 if w.endswith(a):
314 return w[:-len(a)] + b
315 # Default rule: strip known plural suffixes (baseline = 51%).
316 for suffix in ("nen", "en", "n", "e", "er", "s"):
317 if w.endswith(suffix):
318 return w[:-len(suffix)]
319 return w
320 return w
321
322#### VERB CONJUGATION ##############################################################################
323# The verb table was trained on CELEX and contains the top 2000 most frequent verbs.

Callers 1

find_lemmataFunction · 0.90

Calls 1

lenFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…