lemmatization-text-preprocessing
June 9, 2024
0.1 Wordnet Lemmatizer
Lemmatization technique is like stemming. The output we will get after lemmatization is called
‘lemma’, which is a root word rather than root stem, the output of stemming. After lemmatization,
we will be getting a valid word that means the same thing.
NLTK provides WordNetLemmatizer class which is a thin wrapper around the wordnet corpus.
This class uses morphy() function to the WordNet CorpusReader class to find a lemma. Let us
understand it with an example −
[19]: ## Q&A,chatbots,text summarization
from [Link] import WordNetLemmatizer
[2]: lemmatizer=WordNetLemmatizer()
[8]: '''
POS- Noun-n
verb-v
adjective-a
adverb-r
'''
[Link]("going",pos='v')
[8]: 'go'
[9]: words=["eating","eats","eaten","writing","writes","programming","programs","history","finally"
[14]: for word in words:
print(word+"---->"+[Link](word,pos='v'))
eating---->eat
eats---->eat
eaten---->eat
writing---->write
writes---->write
programming---->program
programs---->program
history---->history
1
finally---->finally
finalized---->finalize
[16]: [Link]("goes",pos='v')
[16]: 'go'
[18]: [Link]("fairly",pos='v'),[Link]("sportingly")
[18]: ('fairly', 'sportingly')
[ ]:
[ ]:
[ ]: