← Master Index
Vol. 09 Module 9.1 Lecture

Lemmatization

NLP Basics

How This Lesson Fits the Module & Volume

Stemming chops; lemmatization looks up the canonical dictionary form—the lemma—using vocabulary knowledge and usually part-of-speech. It sits between surface tokens and higher analyses like POS tagging.

Use lemmas when you need readable normalization, better morphological grouping than stems, or features for classical models without non-word stems. Contextual embeddings later often make aggressive lemmatization optional.

Learning Objectives

By the end of this lesson, students should be able to:

  • Define lemmatization and the lemma.
  • Explain why POS context improves lemmatization (meeting noun vs verb).
  • Lemmatize with WordNetLemmatizer and spaCy.
  • Compare stemming vs lemmatization on irregular verbs and plurals.
  • Choose lemmatization appropriately for search, analytics, and neural pipelines.
  • Avoid lemmatizing before tasks that need surface forms (exact match, some NER).
Definition

Lemmatization maps a word form to its lemma—the canonical dictionary citation form (e.g., ran / runningrun; bettergood when tagged as adjective). Unlike stemming, the result is typically a valid word.

Why POS Matters

The string meeting is a noun in “the meeting ended” and a verb in “we are meeting.” A lemmatizer without POS may leave both as meeting; with POS, the verb becomes meet. That is why spaCy lemmatizes inside a full pipeline and why NLTK’s WordNet lemmatizer accepts a POS hint.

FormPOSLemma
runningVERBrun
runningNOUN (the running)running
miceNOUNmouse
betterADJgood
areAUX/VERBbe

Code: NLTK and spaCy

import nltk import spacy from nltk.stem import WordNetLemmatizer, PorterStemmer nltk.download("wordnet", quiet=True) nltk.download("omw-1.4", quiet=True) wnl = WordNetLemmatizer() print(wnl.lemmatize("running", pos="v")) # run print(wnl.lemmatize("running", pos="n")) # running print(wnl.lemmatize("better", pos="a")) # good nlp = spacy.load("en_core_web_sm") doc = nlp("The mice were running better today.") for t in doc: print(f"{t.text:10} lemma={t.lemma_:10} pos={t.pos_}") # Contrast with stemming ps = PorterStemmer() print("studies ->", ps.stem("studies"), "vs", wnl.lemmatize("studies", pos="n"))

Choosing Normalization

Prefer lemmas

  • Analytics dashboards / word clouds.
  • Morphology-aware classical features.
  • Need valid words for humans.

Prefer stems

  • Ultra-fast search indexing.
  • Acceptable non-word stems.
  • Legacy IR systems.

Prefer neither

  • Pretrained transformers.
  • Subword BPE already shares forms.
  • Exact string matching tasks.

Strengths

  • Readable, linguistically motivated.
  • Handles many irregular forms.
  • Integrates cleanly with spaCy docs.

Tradeoffs

  • Needs POS / model download.
  • Slower than Porter stemming.
  • Language resources required.
Common Misconception

“Lemmatization always improves accuracy.” Collapsing Apple (org) and apple (fruit) via lowercasing + lemmatization can hurt NER and entity-sensitive tasks. Normalize only after you know which distinctions matter.

Knowledge Check

  1. Short Answer: What is a lemma? Answer: The canonical dictionary citation form of a word.
  2. True/False: Lemmatization outputs are usually valid words. Answer: True.
  3. Multiple Choice: Lemmatizing running as a verb typically yields: (a) runn, (b) run, (c) runningly. Answer: (b).
  4. Short Answer: Why pass POS to WordNetLemmatizer? Answer: The correct lemma can depend on part of speech.
  5. True/False: spaCy exposes lemmas on each token as token.lemma_. Answer: True.
  6. Multiple Choice: Compared to stemming, lemmatization is generally: (a) faster but cruder, (b) slower but more precise, (c) identical. Answer: (b).
  7. Short Answer: When might you skip lemmatization? Answer: Transformer/subword pipelines or tasks needing exact surface forms.
  8. True/False: better as an adjective lemmatizes to good. Answer: True (with proper POS).
  9. Multiple Choice: Lemmatization belongs closest to: (a) spectrogram filtering, (b) morphological normalization, (c) gradient clipping. Answer: (b).
  10. Short Answer: Which lecture supplies the POS tags lemmatizers rely on? Answer: POS Tagging.

Key Takeaways

  • Lemmatization maps forms to dictionary lemmas, guided by POS.
  • It is cleaner than stemming but more expensive.
  • Use it for readable normalization and classical features; often skip for transformers.
  • Do not blindly lemmatize entity-sensitive text.
  • Next, POS Tagging labels each token’s grammatical category.
Trainer’s Guide

Hands-on idea: Lemmatize a paragraph with and without POS hints in NLTK; list disagreements with spaCy.

Discussion prompt: For product search, do users benefit more from stems, lemmas, or learned query expansion?

Recap: Lemmatization yields true base forms when morphology and POS are known. Continue with POS Tagging.