The Wayback Machine - https://web.archive.org/web/20240601141223/https://www.geeksforgeeks.org/python-lemmatization-with-textblob/
Open In App

Python | Lemmatization with TextBlob

Last Updated : 24 Sep, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

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: 
 

Python3




# 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

 


Similar Reads

Python | Tokenize text using TextBlob
TextBlob module is a Python library and offers a simple API to access its methods and perform basic NLP tasks. It is built on the top of NLTK module. Install TextBlob using the following commands in terminal: pip install -U textblob python -m textblob.download_corpora This will install TextBlob and download the necessary NLTK corpora. The above ins
3 min read
Python | Part of Speech Tagging using TextBlob
TextBlob module is used for building programs for text analysis. One of the more powerful aspects of the TextBlob module is the Part of Speech tagging. Install TextBlob run the following commands: $ pip install -U textblob $ python -m textblob.download_corpora This will install TextBlob and download the necessary NLTK corpora. The above installatio
3 min read
Python | PoS Tagging and Lemmatization using spaCy
spaCy is one of the best text analysis library. spaCy excels at large-scale information extraction tasks and is one of the fastest in the world. It is also the best way to prepare text for deep learning. spaCy is much faster and accurate than NLTKTagger and TextBlob. How to Install ? pip install spacy python -m spacy download en_core_web_sm Top Fea
2 min read
Python - Lemmatization Approaches with Examples
The following is a step by step guide to exploring various kinds of Lemmatization approaches in python along with a few examples and code implementation. It is highly recommended that you stick to the given flow unless you have an understanding of the topic, in which case you can look up any of the approaches given below. What is Lemmatization? In
14 min read
Python | Lemmatization with NLTK
Lemmatization is a fundamental text pre-processing technique widely applied in natural language processing (NLP) and machine learning. Serving a purpose akin to stemming, lemmatization seeks to distill words to their foundational forms. In this linguistic refinement, the resultant base word is referred to as a "lemma." The article aims to explore t
6 min read
Python | Sort Python Dictionaries by Key or Value
There are two elements in a Python dictionary-keys and values. You can sort the dictionary by keys, values, or both. In this article, we will discuss the methods of sorting dictionaries by key or value using Python. Need for Sorting Dictionary in PythonWe need sorting of data to reduce the complexity of the data and make queries faster and more eff
5 min read
str() vs repr() in Python
In Python, the str() and repr() functions are used to obtain string representations of objects. While they may seem similar at first glance, there are some differences in how they behave. Both of the functions can be helpful in debugging or printing useful information about the object. Python str() In the given example, we are using the str() funct
3 min read
Division Operators in Python
Division Operators allow you to divide two numbers and return a quotient, i.e., the first number or number at the left is divided by the second number or number at the right and returns the quotient. Division Operators in PythonThere are two types of division operators: Float divisionInteger division( Floor division)When an integer is divided, the
5 min read
Generators in Python
A Generator in Python is a function that returns an iterator using the Yield keyword. In this article, we will discuss how the generator function works in Python. Generator Function in PythonA generator function in Python is defined like a normal function, but whenever it needs to generate a value, it does so with the yield keyword rather than retu
4 min read
Time Functions in Python | Set 1 (time(), ctime(), sleep()...)
Python has defined a module, "time" which allows us to handle various operations regarding time, its conversions and representations, which find its use in various applications in life. The beginning of time started measuring from 1 January, 12:00 am, 1970 and this very time is termed as "epoch" in Python. Operations on Time in Python Python time.t
4 min read