

def step_1b(w):
    ' Step 1b handles -ed and -ing suffixes (or -edly and -ingly).\n        Removes double consonants at the end of the stem and adds -e to some words.\n    '
    if (w.endswith('y') and w.endswith(('edly', 'ingly'))):
        w = w[:(- 2)]
    if w.endswith(('ed', 'ing')):
        if w.endswith('ied'):
            return (((len(w) == 4) and w[:(- 1)]) or w[:(- 2)])
        if w.endswith('eed'):
            return ((R1(w).endswith('eed') and w[:(- 1)]) or w)
        for suffix in ('ed', 'ing'):
            if (w.endswith(suffix) and has_vowel(w[:(- len(suffix))])):
                w = w[:(- len(suffix))]
                if w.endswith(('at', 'bl', 'iz')):
                    return (w + 'e')
                if is_double_consonant(w[(- 2):]):
                    return w[:(- 1)]
                if is_short(w):
                    return (w + 'e')
    return w

dataset/ETHPy150Open clips/pattern/pattern/vector/stemmer.py step_1b/original