Search code examples
pythonnltk

Is there a way to correctly remove the tense or plural from a word?


Is it possible to to change words like running, helping, cooks, finds and happily into run, help, cook, find and happy using nltk?


Solution

  • There are some stemming algorithms implemented in nltk. It looks like Lancaster stemming algorithm will work for you.

    >>> from nltk.stem.lancaster import LancasterStemmer
    >>> st = LancasterStemmer()
    >>> st.stem('happily')
    'happy'
    >>> st.stem('cooks')
    'cook'
    >>> st.stem('helping')
    'help'
    >>> st.stem('running')
    'run'
    >>> st.stem('finds')
    'find'