Articles → NLP → Chinking In NLP

Chinking In NLP






Purpose






The quick brown fox jumps over the lazy dog




Noun

A noun is a word that names a person, place, thing, or idea.
Example: The dog is barking.

Verb

A verb is a word that shows an action or a state of being.
Example: She runs every morning.

Preposition

A preposition is a word that shows the relationship between a noun and another word in a sentence. It often tells us about place, time, direction, or position.
Example: The book is on the table.


Example




import nltk
from nltk import pos_tag, word_tokenize, RegexpParser

sentence = "The quick brown fox jumps over the lazy dog"
tokens = word_tokenize(sentence)
tagged = pos_tag(tokens)

# First, chunk everything
grammar = r"""
  NP: {<.*>+}         # Chunk everything
      }<VB.*|IN>+{    # Chink verbs AND prepositions
"""

chunk_parser = RegexpParser(grammar)
tree = chunk_parser.parse(tagged)

print(tree)



Output


Picture showing the output of chinking in NLP



Posted By  -  Karan Gupta
 
Posted On  -  Thursday, September 4, 2025

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250