← Master Index
Vol. 09 Module 9.1 Lecture

POS Tagging

NLP Basics

How This Lesson Fits the Module & Volume

Module 9.1 so far prepared surface text: corpus, cleaning, tokenization, and morphological normalization. Part-of-speech (POS) tagging is the first major linguistic annotation layer—assigning grammatical categories to tokens.

POS tags power better lemmatization, feature engineering, and are prerequisites for NER quality analysis and dependency parsing.

Learning Objectives

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

  • Define POS tagging and list common Universal Dependencies (UD) coarse tags.
  • Explain ambiguity (book as noun vs verb) and why context models matter.
  • Tag text with spaCy and NLTK; read pos_ vs fine-grained tag_.
  • Use POS filters for information extraction (e.g., extract nouns/adjectives).
  • Describe evaluation with accuracy / token-level F1 on tagged corpora.
  • Know when neural end-to-end models hide POS versus when explicit tags still help.
Definition

POS tagging assigns each token a part-of-speech label (noun, verb, adjective, …) according to its role in context. Systems may use coarse Universal POS tags or fine-grained tagsets (e.g., Penn Treebank).

Common Coarse Tags (UD)

TagMeaningExamples
NOUNCommon nouncat, algorithm
PROPNProper nounLondon, CUDA
VERBVerbrun, classify
ADJAdjectivefast, neural
ADVAdverbquickly, very
ADPAdpositionin, on, of
DETDeterminerthe, a
PRONPronounit, they
PUNCTPunctuation. , !

Tagging in Practice

import nltk import spacy nltk.download("averaged_perceptron_tagger_eng", quiet=True) nltk.download("punkt_tab", quiet=True) from nltk import pos_tag, word_tokenize text = "They book flights to NYC and read a book." print(pos_tag(word_tokenize(text))) # Penn tags: book/VBP vs book/NN nlp = spacy.load("en_core_web_sm") doc = nlp(text) for t in doc: print(f"{t.text:10} upos={t.pos_:6} fine={t.tag_:6} lemma={t.lemma_}") # Simple IE: content words only content = [t.lemma_ for t in doc if t.pos_ in {"NOUN", "PROPN", "VERB", "ADJ"}] print(content)

Ambiguity and Models

Rule / lexicon

  • Fast baselines.
  • Fail on unknown words.
  • Weak on ambiguity.

Statistical taggers

  • HMM, perceptron (NLTK).
  • Learn from treebanks.
  • Strong classical default.

Neural taggers

  • spaCy’s CNN/transformer.
  • Contextual embeddings.
  • State of the art accuracy.

Why Explicit POS Still Helps

  • Debuggable linguistic features.
  • Guides lemmatization & chunking.
  • Useful constraints for pattern IE.

Limitations

  • Errors cascade to parsers.
  • Domain shift (social media, code).
  • End-to-end LLMs may not expose tags.
Common Misconception

“POS tags are unique per word type.” Tags are assigned per token occurrence in context. The type book can be VERB or NOUN in the same document.

Knowledge Check

  1. Short Answer: What does POS tagging assign? Answer: A grammatical category label to each token in context.
  2. True/False: The word type book always receives the same POS tag. Answer: False—it depends on context.
  3. Multiple Choice: UD tag PROPN means: (a) pronoun, (b) proper noun, (c) preposition. Answer: (b).
  4. Short Answer: Difference between spaCy pos_ and tag_? Answer: pos_ is coarse Universal POS; tag_ is fine-grained (e.g., Penn).
  5. True/False: POS tagging should run on stop-word-stripped text only. Answer: False—function words are part of the syntax.
  6. Multiple Choice: NLTK pos_tag commonly returns: (a) UD only, (b) Penn Treebank-style tags, (c) dependency arcs. Answer: (b).
  7. Short Answer: Give one engineering use of POS filters. Answer: Extract nouns/adjectives for keywords, or constrain pattern-based IE.
  8. True/False: Domain shift can degrade tagger accuracy. Answer: True.
  9. Multiple Choice: POS errors most directly hurt: (a) JPEG compression, (b) lemmatization and parsing, (c) SGD momentum. Answer: (b).
  10. Short Answer: Which lecture finds spans like people and organizations? Answer: Named Entity Recognition (NER).

Key Takeaways

  • POS tagging labels tokens with grammatical categories in context.
  • Ambiguity requires contextual models, not per-word dictionaries alone.
  • spaCy and NLTK provide production-ready taggers for pipelines.
  • Tags support lemmatization, IE patterns, and parsing.
  • Next, Named Entity Recognition (NER) labels real-world entity spans.
Trainer’s Guide

Hands-on idea: Ask students to find five POS ambiguities in tech support tickets and check spaCy’s decisions.

Discussion prompt: For an LLM app, when would you still run an explicit POS tagger instead of prompting?

Recap: POS tags expose grammar per token and unlock cleaner linguistic pipelines. Continue with Named Entity Recognition (NER).