Open In App
Related Articles

Python | Lemmatization with TextBlob

Improve Article
Save Article
Like Article

Lemmatization is the process of grouping together the different inflected forms of a word so they can be analyzed as a single item. Lemmatization is similar to stemming but it brings context to the words. So it links words with similar meanings to one word.
Text preprocessing includes both Stemming as well as Lemmatization. Many times people find these two terms confusing. Some treat these two as the same. Actually, lemmatization is preferred over Stemming because lemmatization does morphological analysis of the words.
Applications of lemmatization are: 

  • Used in comprehensive retrieval systems like search engines.
  • Used in compact indexing.


Examples of lemmatization :

-> rocks : rock
-> corpora : corpus
-> better : good

One major difference with stemming is that lemmatize takes a part of speech parameter, “pos” If not supplied, the default is “noun.”
Below is the implementation of lemmatization words using TextBlob: 


# from textblob lib import Word method
from textblob import Word
# create a Word object.
u = Word("rocks")
# apply lemmatization.
print("rocks :", u.lemmatize())
# create a Word object.
v = Word("corpora")
# apply lemmatization.
print("corpora :", v.lemmatize())
# create a Word object.
w = Word("better")
# apply lemmatization with
# parameter "a", "a" denotes adjective.
print("better :", w.lemmatize("a"))

Output : 

rocks : rock
corpora : corpus
better : good


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 24 Sep, 2021
Like Article
Save Article
Similar Reads
Complete Tutorials