'Returns the base form of the given inflected verb, using a rule-based approach.
This is problematic if a verb ending in -e is given in the past tense or gerund.'

def find_lemma(self, verb):

    v = verb.lower()
    b = False
    if (v in ("'m", "'re", "'s", "n't")):
        return 'be'
    if (v in ("'d", "'ll")):
        return 'will'
    if (v in "'ve"):
        return 'have'
    if v.endswith('s'):
        if (v.endswith('ies') and (len(v) > 3) and (v[(-4)] not in VOWELS)):
            return (v[:(-3)] + 'y')
        if v.endswith(('sses', 'shes', 'ches', 'xes')):
            return v[:(-2)]
        return v[:(-1)]
    if (v.endswith('ied') and (re_vowel.search(v[:(-3)]) is not None)):
        return (v[:(-3)] + 'y')
    if (v.endswith('ing') and (re_vowel.search(v[:(-3)]) is not None)):
        v = v[:(-3)]
        b = True
    if (v.endswith('ed') and (re_vowel.search(v[:(-2)]) is not None)):
        v = v[:(-2)]
        b = True
    if b:
        if ((len(v) > 3) and (v[(-1)] == v[(-2)]) and (v[(-3)] in VOWELS) and (v[(-4)] not in VOWELS) and (not v.endswith('ss'))):
            return v[:(-1)]
        if v.endswith(('ick', 'ack')):
            return v[:(-1)]
        if v.endswith(('v', 'z', 'c', 'i')):
            return (v + 'e')
        if (v.endswith('g') and v.endswith(('dg', 'lg', 'ng', 'rg'))):
            return (v + 'e')
        if (v.endswith(('b', 'd', 'g', 'k', 'l', 'm', 'r', 's', 't')) and (len(v) > 2) and (v[(-2)] in VOWELS) and (not (v[(-3)] in VOWELS)) and (not v.endswith('er'))):
            return (v + 'e')
        if (v.endswith('n') and v.endswith(('an', 'in')) and (not v.endswith(('ain', 'oin', 'oan')))):
            return (v + 'e')
        if (v.endswith('l') and (len(v) > 1) and (v[(-2)] not in VOWELS)):
            return (v + 'e')
        if (v.endswith('f') and (len(v) > 2) and (v[(-2)] in VOWELS) and (v[(-3)] not in VOWELS)):
            return (v + 'e')
        if v.endswith('e'):
            return (v + 'e')
        if v.endswith(('th', 'ang', 'un', 'cr', 'vr', 'rs', 'ps', 'tr')):
            return (v + 'e')
    return v
