Articles → NLP → Chunking In NLPChunking In NLPThis article describes chunking in NLP.What Is Chunking? In NLP, chunking is the process of grouping words into meaningful units—typically phrases such as noun phrases (NP), verb phrases (VP), etc.Example Consider the following sentence.The quick brown fox jumps over the lazy dogThe table after tokenization and POS.TokenPOSTheDTQuickJJBrownJJFoxNNJumpsVBZOverINTheDTLazyJJDogNNAfter chunking[The quick brown fox] (NP)[jumps] (VP)[over the lazy dog] (PP)Noun PhraseA noun phrase is a group of words centred around a noun (the head of the phrase), along with its modifiers (adjectives, determiners, etc.). For example, the tall building → Head = building (noun), Modifiers = the, tall.Verb Phrase A verb phrase is the predicate part — it contains the main verb and everything attached to it.In this sentence, jumps over the lazy dog = VPMain verb = jumpsComplement (extra info) = over the lazy dog (a PP)Prepositional Phrase (PP) A prepositional phrase starts with a preposition and ends with its object (a noun phrase).Here, over the lazy dog = PPPreposition = overObject (NP) = the lazy dogPrerequisite To begin with, install the following packages.python.exe -m pip install --upgrade numpy pandas python.exe -m pip install --upgrade numpy pandas scikit-learnAfter the installation, download the following packages.punktaveraged_perceptron_taggerExample Consider the following example: -import nltk from nltk import pos_tag, word_tokenize, RegexpParser # Sample sentence sentence = "The quick brown fox jumps over the lazy dog" # Tokenize and POS tagging tokens = word_tokenize(sentence) tagged = pos_tag(tokens) # Define a simple grammar for noun phrases (NP) grammar = "NP: {<DT>?<JJ>*<NN>}" # Create a chunk parser chunk_parser = RegexpParser(grammar) # Parse the sentence tree = chunk_parser.parse(tagged) print(tree)Output Posted By - Karan Gupta Posted On - Tuesday, September 2, 2025 Query/Feedback Your Email Id** Subject* Query/Feedback Characters remaining 250**
The quick brown fox jumps over the lazy dog
A noun phrase is a group of words centred around a noun (the head of the phrase), along with its modifiers (adjectives, determiners, etc.). For example, the tall building → Head = building (noun), Modifiers = the, tall.
python.exe -m pip install --upgrade numpy pandas python.exe -m pip install --upgrade numpy pandas scikit-learn
import nltk from nltk import pos_tag, word_tokenize, RegexpParser # Sample sentence sentence = "The quick brown fox jumps over the lazy dog" # Tokenize and POS tagging tokens = word_tokenize(sentence) tagged = pos_tag(tokens) # Define a simple grammar for noun phrases (NP) grammar = "NP: {<DT>?<JJ>*<NN>}" # Create a chunk parser chunk_parser = RegexpParser(grammar) # Parse the sentence tree = chunk_parser.parse(tagged) print(tree)
Query/Feedback