Step 1b handles -ed and -ing suffixes (or -edly and -ingly). Removes double consonants at the end of the stem and adds -e to some words.
(w)
| 128 | return w |
| 129 | |
| 130 | def step_1b(w): |
| 131 | """ Step 1b handles -ed and -ing suffixes (or -edly and -ingly). |
| 132 | Removes double consonants at the end of the stem and adds -e to some words. |
| 133 | """ |
| 134 | if w.endswith("y") and w.endswith(("edly", "ingly")): |
| 135 | w = w[:-2] # Strip -ly for next step. |
| 136 | if w.endswith(("ed", "ing")): |
| 137 | if w.endswith("ied"): |
| 138 | # See -ies in step 1a. |
| 139 | return len(w)==4 and w[:-1] or w[:-2] |
| 140 | if w.endswith("eed"): |
| 141 | # Replace by -ee if preceded by at least one vowel-consonant pair. |
| 142 | return R1(w).endswith("eed") and w[:-1] or w |
| 143 | for suffix in ("ed", "ing"): |
| 144 | # Delete if the preceding word part contains a vowel. |
| 145 | # - If the word ends -at, -bl or -iz add -e (luxuriat => luxuriate). |
| 146 | # - If the word ends with a double remove the last letter (hopp => hop). |
| 147 | # - If the word is short, add e (hop => hope). |
| 148 | if w.endswith(suffix) and has_vowel(w[:-len(suffix)]): |
| 149 | w = w[:-len(suffix)] |
| 150 | if w.endswith(("at", "bl", "iz")): |
| 151 | return w+"e" |
| 152 | if is_double_consonant(w[-2:]): |
| 153 | return w[:-1] |
| 154 | if is_short(w): |
| 155 | return w+"e" |
| 156 | return w |
| 157 | |
| 158 | def step_1c(w): |
| 159 | """ Step 1c replaces suffix -y or -Y by -i if preceded by a non-vowel |
nothing calls this directly
no test coverage detected
searching dependent graphs…