(word, pos=NOUN, custom={})
| 139 | singular_irregular = dict((v,k) for k,v in plural_irregular.iteritems()) |
| 140 | |
| 141 | def singularize(word, pos=NOUN, custom={}): |
| 142 | if word in custom.keys(): |
| 143 | return custom[word] |
| 144 | w = word.lower() |
| 145 | if pos == NOUN and w in singular_irregular: |
| 146 | return singular_irregular[w] |
| 147 | if pos == NOUN and w.endswith((u"ën", "en", "s", "i")): |
| 148 | # auto's => auto |
| 149 | if w.endswith("'s"): |
| 150 | return w[:-2] |
| 151 | # broers => broer |
| 152 | if w.endswith("s"): |
| 153 | return w[:-1] |
| 154 | # academici => academicus |
| 155 | if w.endswith("ici"): |
| 156 | return w[:-1] + "us" |
| 157 | # feeën => fee |
| 158 | if w.endswith(u"ën") and w[:-2] in plural_irregular_een: |
| 159 | return w[:-2] |
| 160 | # bacteriën => bacterie |
| 161 | if w.endswith(u"ën"): |
| 162 | return w[:-2] + "e" |
| 163 | # mogelijkheden => mogelijkheid |
| 164 | if w.endswith("heden"): |
| 165 | return w[:-5] + "heid" |
| 166 | # artikelen => artikel |
| 167 | if w.endswith("elen") and not w.endswith("delen"): |
| 168 | return w[:-2] |
| 169 | # chinezen => chinees |
| 170 | if w.endswith("ezen"): |
| 171 | return w[:-4] + "ees" |
| 172 | # neven => neef |
| 173 | if w.endswith("even") and len(w) > 4 and not is_vowel(w[-5]): |
| 174 | return w[:-4] + "eef" |
| 175 | if w.endswith("en"): |
| 176 | w = w[:-2] |
| 177 | # ogen => oog |
| 178 | if w in ("og","om","ur"): |
| 179 | return w[:-1] + w[-2] + w[-1] |
| 180 | # hoenderen => hoen |
| 181 | if w.endswith("der") and w[:-3] in plural_irregular_deren: |
| 182 | return w[:-3] |
| 183 | # eieren => ei |
| 184 | if w.endswith("er") and w[:-2] in plural_irregular_eren: |
| 185 | return w[:-2] |
| 186 | # dagen => dag (not daag) |
| 187 | if w in plural_irregular_en: |
| 188 | return w |
| 189 | # huizen => huis |
| 190 | if w.endswith("z"): |
| 191 | return w[:-1] + "s" |
| 192 | # brieven => brief |
| 193 | if w.endswith("v"): |
| 194 | return w[:-1] + "f" |
| 195 | # motoren => motor |
| 196 | if w.endswith("or"): |
| 197 | return w |
| 198 | # flessen => fles |
no test coverage detected
searching dependent graphs…