Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Unit 2 — Part-of-Speech (POS) Tagging: Introduction & Tagsets

Lesson 13 of 39 in the free Natural Language Processing notes on Siksha Sarovar, written by Rohit Jangra.

Part-of-Speech (POS) Tagging

POS tagging is the process of assigning a grammatical category (noun, verb, adjective, etc.) to every token in a sentence, based on both its definition and its context.

"Riya reads books."
# Riya  -> Proper Noun
# reads -> Verb
# books -> Noun
# .     -> Punctuation

Why POS Tagging Matters

POS tags are a foundational feature used by almost every later stage of NLP:

  • Parsing needs POS tags to build a syntax tree (Unit 2, next lessons)
  • Lemmatization needs POS to pick the right lemma (recall Unit 1: "running" → "run" only if tagged as a verb)
  • NER uses POS patterns (e.g. sequences of proper nouns) as features
  • Word Sense Disambiguation narrows down possible senses using POS

The Penn Treebank Tagset (Most Common in English NLP)

TagMeaningExample
NNNoun, singular"book"
NNSNoun, plural"books"
NNPProper noun, singular"Riya"
VBVerb, base form"read"
VBDVerb, past tense"read" (past)
VBGVerb, gerund/present participle"reading"
VBZVerb, 3rd person singular present"reads"
JJAdjective"happy"
RBAdverb"quickly"
PRPPersonal pronoun"she"
INPreposition/subordinating conjunction"in", "of", "because"
DTDeterminer"the", "a"
CCCoordinating conjunction"and", "but"
CDCardinal number"2026"

Tagging with NLTK

import nltk
from nltk import pos_tag, word_tokenize

sentence = "Riya quickly finished the difficult assignment."
tokens = word_tokenize(sentence)
tagged = pos_tag(tokens)
print(tagged)
# [('Riya', 'NNP'), ('quickly', 'RB'), ('finished', 'VBD'), ('the', 'DT'),
#  ('difficult', 'JJ'), ('assignment', 'NN'), ('.', '.')]

Why POS Tagging Is Hard — Ambiguity

The same word form can take different tags depending on context:

sentences = [
    "I book a flight ticket.",      # "book" -> VB (verb)
    "I read a good book.",          # "book" -> NN (noun)
]
for s in sentences:
    print(pos_tag(word_tokenize(s)))
# [('I', 'PRP'), ('book', 'VBP'), ('a', 'DT'), ('flight', 'NN'), ('ticket', 'NN'), ('.', '.')]
# [('I', 'PRP'), ('read', 'VBP'), ('a', 'DT'), ('good', 'JJ'), ('book', 'NN'), ('.', '.')]

This is the same fundamental problem as lexical ambiguity from Unit 1 — a single surface word form maps to multiple grammatical categories, and only context disambiguates it. Resolving this correctly is exactly what POS tagging algorithms — covered in the next lesson — are built to do.