def affix_stemmer(words, exception_list=exceptions, strip_pref = True, strip_suf = True):
    """
    :param words: string list

    The affix stemmer works by rule-based stripping. It can work on prefixes,

    >>> affix_stemmer(['yesterday', 'yesterdom', 'yisterweek'])
    'day dom week'

    suffixes,

    >>> affix_stemmer(['likingnes', 'armlich', 'heighli'])
    'liking arm heigh'

    or both

    >>> affix_stemmer(['yisterdayes'])
    'day'

    You can also define whether the stemmer will strip suffixes

    >>> affix_stemmer(['yisterdayes'], strip_suf = False)
    'dayes'

    or prefixes

    >>> affix_stemmer(['yisterdayes'], strip_pref = False)
    'yisterday'

    The stemmer also accepts a user-defined dictionary, that essentially serves
    the function of a dictionary look-up stemmer

    >>> affix_stemmer(['arisnesse'], exception_list = {'arisnesse':'rise'})
    'rise'

    :exception_list:
    :return: string
    """

    for i, w in enumerate(words):

        try:
            words[i] = exception_list[w]

        except:
            if len(w) <= 4:
                continue

            word = w

            if strip_pref:

                for prefix in PREFIXES:
                    if word.startswith(prefix):
                        word = word[len(prefix):]
                        break

            if strip_suf:

                for en in ENDS:

                    if len(word) <= 4:
                        break

                    # Strip suffixes
                    for suffix in SUFFIXES:

                        if len(suffix) <= len(en):
                            break

                        if (word + en).endswith(suffix):
                            word = word[:-len(suffix) + len(en)]
                            break

                    if len(word) <= 4:
                        break

            words[i] = word

    return " ".join(words)
def affix_stemmer ( words , exception_list = exceptions , strip_pref = True , strip_suf = True ) : for i , w in enumerate ( words ) : try : words [ i ] = exception_list [ w ] except : if len ( w ) <= 4 : continue word = w if strip_pref : for prefix in PREFIXES : if word . startswith ( prefix ) : word = word [ len ( prefix ) : ] break if strip_suf : for en in ENDS : if len ( word ) <= 4 : break for suffix in SUFFIXES : if len ( suffix ) <= len ( en ) : break if ( word + en ) . endswith ( suffix ) : word = word [ : - len ( suffix ) + len ( en ) ] break if len ( word ) <= 4 : break words [ i ] = word return " " . join ( words )
:param words: string list

    The affix stemmer works by rule-based stripping. It can work on prefixes,

    >>> affix_stemmer(['yesterday', 'yesterdom', 'yisterweek'])
    'day dom week'

    suffixes,

    >>> affix_stemmer(['likingnes', 'armlich', 'heighli'])
    'liking arm heigh'

    or both

    >>> affix_stemmer(['yisterdayes'])
    'day'

    You can also define whether the stemmer will strip suffixes

    >>> affix_stemmer(['yisterdayes'], strip_suf = False)
    'dayes'

    or prefixes

    >>> affix_stemmer(['yisterdayes'], strip_pref = False)
    'yisterday'

    The stemmer also accepts a user-defined dictionary, that essentially serves
    the function of a dictionary look-up stemmer

    >>> affix_stemmer(['arisnesse'], exception_list = {'arisnesse':'rise'})
    'rise'

    :exception_list:
    :return: string