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

Function singularize

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

Source from the content-addressed store, hash-verified

78#### SINGULARIZE ###################################################################################
79
80def singularize(word, pos=NOUN, custom={}):
81 if word in custom:
82 return custom[word]
83 w = word.lower()
84 # Common articles, determiners, pronouns:
85 if pos in ("DT", "PRP", "PRP$", "WP", "RB", "IN"):
86 if w == "du" : return "de"
87 if w == "ces": return "ce"
88 if w == "les": return "le"
89 if w == "des": return "un"
90 if w == "mes": return "mon"
91 if w == "ses": return "son"
92 if w == "tes": return "ton"
93 if w == "nos": return "notre"
94 if w == "vos": return "votre"
95 if w.endswith(("'", u"’")):
96 return w[:-1] + "e"
97 if w.endswith("nnes"): # parisiennes => parisien
98 return w[:-3]
99 if w.endswith("ntes"): # passantes => passant
100 return w[:-2]
101 if w.endswith("euses"): # danseuses => danseur
102 return w[:-3] + "r"
103 if w.endswith("s"):
104 return w[:-1]
105 if w.endswith(("aux", "eux", "oux")):
106 return w[:-1]
107 if w.endswith("ii"):
108 return w[:-1] + "o"
109 if w.endswith(("ia", "ma")):
110 return w[:-1] + "um"
111 if "-" in w:
112 return singularize(w.split("-")[0]) + "-" + "-".join(w.split("-")[1:])
113 return w
114
115#### VERB CONJUGATION ##############################################################################
116

Callers 1

find_lemmataFunction · 0.90

Calls 1

splitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…