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

Function step_1b

pattern/vector/stemmer.py:130–156  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

128 return w
129
130def 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
158def step_1c(w):
159 """ Step 1c replaces suffix -y or -Y by -i if preceded by a non-vowel

Callers

nothing calls this directly

Calls 5

lenFunction · 0.85
R1Function · 0.85
has_vowelFunction · 0.85
is_double_consonantFunction · 0.85
is_shortFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…