1 of 19

POS(Parts-Of-Speech) Tagging in NLP

Parts of Speech (PoS) tagging is a fundamental task in Natural Language Processing (NLP) where each word in a sentence is assigned a grammatical category such as noun, verb, adjective or adverb. This process help machines to understand the structure and meaning of sentences by identifying the roles of words and their relationships.

2 of 19

3 of 19

Key Concepts in POS Tagging

  1. Parts of Speech: These are categories like nouns, verbs, adjectives, adverbs, etc that define the role of a word in a sentence.
  2. Tagging: The process of assigning a specific part-of-speech label to each word in a sentence.
  3. Corpus: A large collection of text data used to train POS taggers.

Example of POS Tagging

Consider the sentence: "The quick brown fox jumps over the lazy dog."

After performing POS Tagging, we get:

"The" is tagged as determiner (DT)

"quick" is tagged as adjective (JJ)

"brown" is tagged as adjective (JJ)

"fox" is tagged as noun (NN)

"jumps" is tagged as verb (VBZ)

"over" is tagged as preposition (IN)

"the" is tagged as determiner (DT)

"lazy" is tagged as adjective (JJ)

"dog" is tagged as noun (NN)

Each word is assigned a tag based on its role in the sentence. For example, "quick" and "brown" are adjectives that describe the noun "fox."

4 of 19

5 of 19

6 of 19

Working of POS Tagging

steps involved in POS tagging:

  • Tokenization: The input text is split into individual tokens (words or subwords), this step is necessary for further analysis.
  • Preprocessing: The text is cleaned such as converting it to lowercase and removing special characters, to improve accuracy.
  • Loading a Language Model: Tools like NLTK or SpaCy use pre-trained language models to understand the grammatical rules of the language, these models have been trained on large datasets.
  • Linguistic Analysis: The structure of the sentence is analyzed to understand the role of each word in context.
  • POS Tagging: Each word is assigned a part-of-speech label based on its role in the sentence and the context provided by surrounding words.
  • Evaluation: The results are checked for accuracy. If there are any errors or misclassifications, they are corrected.

7 of 19

Types of POS Tagging

There are different types and each has its strengths and use cases. Let's see few common methods:

1. Rule-Based Tagging

Rule-based POS tagging assigns POS tags based on predefined grammatical rules. These rules are crafted based on morphological features (like word endings) and syntactic context, making the approach highly interpretable and transparent.

Example:

1. Rule: Assign the POS tag "Noun" to words ending in "-tion" or "-ment".

2. Sentence: "The presentation highlighted the key achievements of the project's development."

3. Tagged Output:

  • "presentation" → Noun (N)
  • "highlighted" → Verb (V)
  • "development" → Noun (N)

8 of 19

Chunking in Natural Language Processing is the process of identifying and extracting meaningful phrases from text by grouping related words together. It serves as an intermediate step between Part-of-Speech tagging and full syntactic parsing.

Chunking

9 of 19

Chunking in NLP is the process of breaking down text into smaller, more manageable phrases or "chunks" based on grammatical rules, like grouping words into noun phrases or verb phrases.

It is a shallow parsing technique that helps identify meaningful units within a sentence, such as grouping "the yellow dog" into a single noun phrase, which improves the understanding, extraction, and processing of information for various applications like question answering and summarization. 

How it works

Part-of-Speech (POS) tagging: The process starts by assigning a part-of-speech tag to each word in a sentence (e.g., noun, verb, adjective).

Pattern matching: It then applies predefined grammatical patterns to group consecutive words. For example, a pattern for a noun phrase might be "determiner + adjective + noun".

Phrase identification: Words that fit a specific pattern are grouped together into a single chunk. The result is a sentence broken down into its constituent phrases.

10 of 19

Example

Sentence: "The big dog ran quickly."

POS tags: "The" (DT), "big" (JJ), "dog" (NN), "ran" (VBD), "quickly" (RB)

Chunking pattern: "Determiner + Adjective + Noun"

Identified chunk: "The big dog" (a noun phrase)

11 of 19

1. What is Chunking?

Chunking involves dividing text into syntactically related groups of words called chunks. These chunks represent meaningful units like noun phrases, verb phrases, or prepositional phrases.

Example: Chunking a Simple Sentence

Input: "The quick brown fox jumps over the lazy dog"

After POS Tagging: The/DT quick/JJ brown/JJ fox/NN jumps/VBZ over/IN the/DT lazy/JJ dog/NN

After Chunking: [NP The/DT quick/JJ brown/JJ fox/NN] [VP jumps/VBZ] [PP over/IN] [NP the/DT lazy/JJ dog/NN]

12 of 19

2. Types of Chunks

Noun Phrases (NP) - Groups of words functioning as a noun unit:

"The red car" → [NP The red car]

"My best friend" → [NP My best friend]

Verb Phrases (VP)

Groups containing verbs and their modifiers:

"is running quickly" → [VP is running quickly]

"will have been completed" → [VP will have been completed]

Prepositional Phrases (PP)

Phrases beginning with prepositions:

"in the garden" → [PP in the garden]

"under the table" → [PP under the table]

13 of 19

3. Chunking vs Full Parsing

Full Parsing

Creates complete syntactic tree structure

Computationally expensive

Provides detailed grammatical relationships

Chunking (Shallow Parsing)

Identifies only major phrases

Faster and more robust

Sufficient for many NLP applications

4. Chunking Approaches

Rule-Based Chunking

Uses hand-crafted patterns to identify chunks:

NP Pattern: {<DT>?<JJ>*<NN>}

This pattern matches: Optional determiner + Any number of adjectives + Noun

14 of 19

Regular Expression Patterns

Common chunking patterns:

{<DT><.*>*<NN>} - Determiner followed by words ending with noun

{<JJ><NN>} - Adjective-noun combination

{<NN><IN><NN>} - Noun-preposition-noun pattern

Machine Learning Approach

Train on annotated corpus (like CoNLL-2000)

Learn patterns automatically from data

More flexible than rule-based methods

5. IOB Tagging for Chunking -Chunking uses IOB (Inside-Outside-Begin) notation:

B-NP: Beginning of noun phrase

I-NP: Inside noun phrase

O: Outside any chunk

Example IOB Tagging:

Word: The quick brown fox jumps over

POS: DT JJ JJ NN VBZ IN

Chunk: B-NP I-NP I-NP I-NP O O

15 of 19

6. Chunking with NLTK

Basic Pattern Example:

import nltk

from nltk.chunk import RegexpParser

# Define chunking grammar

grammar = '''

NP: {?*}

PP: {}

VP: {+$}

'''

# Create parser

cp = RegexpParser(grammar)

Processing Steps:

  • Tokenize text into words
  • Apply POS tagging
  • Apply chunking patterns
  • Extract identified chunks

7. Evaluation Metrics

Precision and Recall

Precision: Correctly identified chunks / Total identified chunks

Recall: Correctly identified chunks / Total actual chunks

F-measure: Harmonic mean of precision and recall

Exact Match

Chunk boundaries must match exactly with gold standard.

16 of 19

8. Applications of Chunking

Information Extraction

Extract named entities and relationships

Identify key phrases from documents

Parse product descriptions and reviews

Question Answering

Identify question type from chunk patterns

Extract answer candidates from text

Match question chunks with document chunks

Text Summarization

Identify important noun phrases

Preserve meaningful chunk boundaries

Maintain readability in summaries

17 of 19

9. Challenges in Chunking

Ambiguous Attachments

  • "I saw the man with the telescope"
  • PP "with the telescope" can attach to verb or noun

Coordination

  • "fast and reliable cars"
  • Handling coordinated adjectives within chunks

Nested Structures

  • "The president of the United States"
  • Nested noun phrases within larger phrases

10. Advanced Techniques

Conditional Random Fields (CRFs)

  • Model dependencies between adjacent chunk labels
  • Better handling of sequence information
  • Higher accuracy than simple classification

Neural Chunking

  • Use of RNNs and transformers
  • End-to-end learning from raw text
  • State-of-the-art performance on benchmark datasets

18 of 19

Select the appropriate chunk type from available options:

    • B-NP: Beginning of a Noun Phrase
    • I-NP: Inside/continuation of a Noun Phrase
    • B-VP: Beginning of a Verb Phrase
    • I-VP: Inside/continuation of a Verb Phrase
    • B-PP: Beginning of a Prepositional Phrase (English only)
    • B-ADVP: Beginning of an Adverbial Phrase
    • I-ADVP: Inside/continuation of an Adverbial Phrase
    • O: Outside any chunk (standalone words)

Ensure logical chunk boundaries:

    • Each chunk should start with a B- tag
    • Continuation words should use I- tags
    • Standalone words should be marked as O

19 of 19

Lexicon

POS

Chunk

John

NNP

B-NP

cut

VB

B-VP

an

DT

B-NP

apple

NN

I-NP

with

IN

B-PP

a

DT

B-NP

knife

NN

I-NP