Understanding lemmatization

Lemmatization is the process in which we transform the word into a form with a different word category. The word formed after lemmatization is entirely different. The built-in morphy() function is used for lemmatization in WordNetLemmatizer. The inputted word is left unchanged if it is not found in WordNet. In the argument, pos refers to the part of speech category of the inputted word.

Consider an example of lemmatization in NLTK:

>>> import nltk
>>> from nltk.stem import WordNetLemmatizer
>>> lemmatizer_output=WordNetLemmatizer()
>>> lemmatizer_output.lemmatize('working')
'working'
>>> lemmatizer_output.lemmatize('working',pos='v')
'work'
>>> lemmatizer_output.lemmatize('works')
'work'

The WordNetLemmatizer library may be defined as a wrapper around the so-called WordNet corpus, and it makes use of the morphy()function present in WordNetCorpusReader to extract a lemma. If no lemma is extracted, then the word is only returned in its original form. For example, for works, the lemma returned is the singular form, work.

Let's consider the following code that illustrates the difference between stemming and lemmatization :

>>> import nltk
>>> from nltk.stem import PorterStemmer
>>> stemmer_output=PorterStemmer()
>>> stemmer_output.stem('happiness')
'happi'
>>> from nltk.stem import WordNetLemmatizer
>>> lemmatizer_output=WordNetLemmatizer()
>>> lemmatizer_output.lemmatize('happiness')
'happiness'

In the preceding code, happiness is converted to happi by stemming. Lemmatization doesn't find the root word for happiness, so it returns the word happiness.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset