Sets the initial y, or y after a vowel, to Y. Of course, y is interpreted as a vowel and Y as a consonant.
(w)
| 294 | return "".join(ch) |
| 295 | |
| 296 | def upper_consonant_y(w): |
| 297 | """ Sets the initial y, or y after a vowel, to Y. |
| 298 | Of course, y is interpreted as a vowel and Y as a consonant. |
| 299 | """ |
| 300 | a = [] |
| 301 | p = None |
| 302 | for ch in w: |
| 303 | if ch == "y" and (p is None or p in VOWELS): |
| 304 | a.append("Y") |
| 305 | else: |
| 306 | a.append(ch) |
| 307 | p = ch |
| 308 | return "".join(a) |
| 309 | |
| 310 | # If we stemmed a word once, we can cache the result and reuse it. |
| 311 | # By default, keep a history of a 10000 entries (<500KB). |