liveBook · Manning

Vocabulary normalization

As explained in Natural Language Processing in Action, Second Edition

Vocabulary normalization is the transformation of semantically or functionally similar lexical forms into shared representations to reduce the number of distinct vocabulary items.

Vocabulary normalization combines tokens that mean or function similarly under a shared form. A smaller vocabulary needs fewer retained tokens and can strengthen associations across different spellings, but every merge discards a distinction. section 2.3.2

Choose a transformation that fits the distinctions your pipeline needs:

  • Case folding maps “House” to “house.” It reduces capitalization variants, but may erase the difference between “doctor” and the proper noun “Doctor.” section 2.3.2
  • Stemming strips word endings. Porter stemming turns “fairly” into “fairli,” while Snowball stemming produces “fair.” section 2.3.2
  • Lemmatization can depend on part of speech: WordNet maps “better” to “good” when given the adjective tag, but leaves it unchanged without that tag. section 2.3.2
>>> nltk.download('wordnet')
True
>>> nltk.download('omw-1.4')
True
>>> from nltk.stem import WordNetLemmatizer
>>> lemmatizer = WordNetLemmatizer()
>>> lemmatizer.lemmatize("better")     #1
'better'
>>> lemmatizer.lemmatize("better", pos="a")    #2
'good'
>>> lemmatizer.lemmatize("good", pos="a")
'good'
>>> lemmatizer.lemmatize("goods", pos="a")
'goods'
>>> lemmatizer.lemmatize("goods", pos="n")
'good'
>>> lemmatizer.lemmatize("goodness", pos="n")
'goodness'
>>> lemmatizer.lemmatize("best", pos="a")
'best'

Try the WordNet listing to see how supplying a part-of-speech tag changes which forms are combined. section 2.3.2

How Natural Language Processing in Action, Second Edition covers it

How deep it goes
Works through case folding, stemming, and part-of-speech-sensitive lemmatization with Python outputs.
Examples
Compares capitalization variants, NLTK stemmer outputs, and WordNet lemmas with and without part-of-speech tags.
What it assumes
Assumes familiarity with tokens and NLP pipelines; demonstrates the transformations through short Python examples.
What you can do after
Apply it via Python and NLTK while weighing vocabulary reduction against lost capitalization distinctions.
How it connects
Links tokenization and bag-of-words features to vocabulary size, overfitting, and named entity recognition.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Natural Language Processing in Action, Second Edition. The section links point to the parts of the book it draws on.