def upper_consonant_y(w):
    a = []
    p = None
    for ch in w:
        if ch == "y" and (p is None or p in VOWELS):
            a.append("Y")
        else:
            a.append(ch)
        p = ch
    return "".join(a)

# If we stemmed a word once, we can cache the result and reuse it.
# By default, keep a history of a 10000 entries (<500KB).
Sets the initial y, or y after a vowel, to Y.
dataset/ETHPy150Open clips/pattern/pattern/vector/stemmer.py/upper_consonant_y