Natural Language Processing · Intermediate level

Intermediate level · Module 5: Part-of-Speech Tagging and Hidden Markov Models · Lesson 1 of 3

Parts of Speech and Tagging with spaCy

Learners identify nouns, verbs, adjectives and other parts of speech, and use spaCy's tagger to extract information such as the actions and objects in requests.

In this lesson you will

  • Name the main parts of speech and the universal tag set
  • Use POS tags to extract useful patterns

Key concepts

part of speechuniversal POS tagstoken.pos_ and token.tag_ambiguitynoun phrases

The lesson

A part of speech (POS) is a word's grammatical role: noun, verb, adjective, adverb, pronoun and so on. spaCy assigns the universal tag set to token.pos_ (NOUN, VERB, ADJ…) and a finer, language-specific tag to token.tag_.

Words can be ambiguous: 'book' is a noun in 'my exam book' and a verb in 'book a room'. Taggers use context to decide, which is exactly the problem HMMs solve.

Tags help extraction. In service requests, the main verb and its object ('replace ID card', 'send transcript') describe what is asked for. doc.noun_chunks gives noun phrases such as 'my student ID card'.

Step by step

  1. Tag 20 service-request messages with spaCy.
  2. Print each token with pos_ and find two ambiguous words.
  3. Extract the main verb and noun chunks from each request.
  4. Count the most common requested actions.

Practice activity

Extract a table of requested actions and objects from 50 synthetic service requests.

Expected result: A table of verb-object pairs with sensible counts and noted tagging errors.

Check your understanding

  1. Give an example of POS ambiguity.

    Show answer

    'book' as a noun ('my book') and as a verb ('book a room').

  2. What does doc.noun_chunks return?

    Show answer

    Noun phrases, such as 'my student ID card'.

Further learning

Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.