How to do chunking in Python

Chunking means getting a chunk of text. A meaningful piece of text from the full text.

One of the main goals of chunking is to group into what is known as “noun phrases.” These are phrases of one or more words that contain a noun, maybe some descriptive words, maybe a verb, and maybe something like an adverb. The idea is to group nouns with the words that are in relation to them.

Sample Output

How to do chunking in Python
How to do chunking in Python

This can give us an idea about what type of adjectives are being used for the nouns, whether they are positive or negative keywords

A Wordcloud can be plotted for all the adjectives to understand overall sentiment or for all the nouns to understand what are the nouns being talked about

Sentiment score can be generated by checking if all the adjectives used are positive or negative


Chunking using multiple grammar rules

Instead of just extracting nouns or adjectives, you can also extract specific combinations of Parts of Speech, e.g. an Adverb-Adjective-Noun combination. You can specify the grammar rules for chunking.

Sample Output:

Chunking multiple grammar rules in Python
Chunking multiple grammar rules in Python

Author Details
Lead Data Scientist
Farukh is an innovator in solving industry problems using Artificial intelligence. His expertise is backed with 10 years of industry experience. Being a senior data scientist he is responsible for designing the AI/ML solution to provide maximum gains for the clients. As a thought leader, his focus is on solving the key business problems of the CPG Industry. He has worked across different domains like Telecom, Insurance, and Logistics. He has worked with global tech leaders including Infosys, IBM, and Persistent systems. His passion to teach inspired him to create this website!

Leave a Reply!

Your email address will not be published. Required fields are marked *