Lemmatizing Words with NLTK: What the WordNet Lemmatizer Changes and When to Use It
A practical review of lemmatization with NLTK's WordNet lemmatizer: how it works, how it differs from stemming, why part-of-speech tags matter, and when to keep the original text.
Lemmatization reduces an inflected word to its dictionary form, or lemma: "cats" becomes "cat" and "was" becomes "be". In Python's Natural Language Toolkit (NLTK), the usual tool is the WordNet lemmatizer. This review explains what it changes, where it helps, where it falls short, and when you should keep the original text.
Is the NLTK lemmatizer suitable for your use?
The NLTK lemmatizer is a good fit when you need to group word forms for counting, searching, matching or feature extraction, and you want results that are still real English words. Its main advantage over a stemmer is readability: a lemma is a valid dictionary entry, not a truncated fragment.
The key tradeoff is that accuracy depends on part-of-speech information. By default, the WordNet lemmatizer treats every word as a noun. If you don't supply the correct part of speech, many verbs and adjectives pass through unchanged. Getting good results therefore usually means adding a tagging step, which adds processing and its own errors.
Plain, unlemmatized text is the better choice when wording, tense, number or tone matters. Examples include text shown to readers, quotations, legal or medical wording, translation input, and any task where "saw" (the tool) must stay distinct from "see". Plain text is also preferable for languages other than English, because WordNet's lemmatization in NLTK is built around English.
What lemmatization actually changes
Lemmatization changes the stored characters of each token. The output is new text, not a visual effect. Unlike reversal, mirroring or Unicode "font" styling, it does not alter character order, glyph appearance or code points for display. It replaces a word form with another word form. For example, "geese" becomes "geese" or "goose" depending on whether the lookup finds an entry.
NLTK's WordNetLemmatizer relies on WordNet's morphological processing, called morphy. This combines suffix-stripping rules with exception lists for irregular forms, then checks the candidate against the WordNet database for the given part of speech. If no valid lemma is found, the word is returned unchanged. The lemmatizer does not raise an error and does not guess.
The lemmatizer works on one word at a time. It doesn't split sentences into words, strip punctuation or read context. Those steps come from a tokenizer and, ideally, a part-of-speech tagger that you run first.
Why part of speech matters
The lemmatize method accepts a pos argument. The documented values are "n" (noun, the default), "v" (verb), "a" (adjective), "r" (adverb) and "s" (satellite adjective). The examples below show behavior commonly cited in NLTK's documentation and tutorials. They are illustrative and were not produced by a test run for this article.
from nltk.stem import WordNetLemmatizer
lemmatizer = WordNetLemmatizer()
lemmatizer.lemmatize("cats") # 'cat' (noun by default)
lemmatizer.lemmatize("running") # 'running' (treated as a noun)
lemmatizer.lemmatize("running", pos="v") # 'run'
lemmatizer.lemmatize("better", pos="a") # 'good'
The second and third lines show the most common surprise for new users. Without a verb tag, "running" is left alone because it is a valid noun in WordNet.
Supplying tags automatically
A typical workflow tokenizes the text, tags it with nltk.pos_tag, and maps the Penn Treebank tags it returns to WordNet's categories. Tags starting with J map to adjective, V to verb, N to noun and R to adverb. Anything else is usually treated as a noun.
import nltk
from nltk.corpus import wordnet
from nltk.stem import WordNetLemmatizer
def to_wordnet_pos(tag):
if tag.startswith("J"):
return wordnet.ADJ
if tag.startswith("V"):
return wordnet.VERB
if tag.startswith("R"):
return wordnet.ADV
return wordnet.NOUN
lemmatizer = WordNetLemmatizer()
tokens = nltk.word_tokenize("The striped bats were hanging on their feet")
lemmas = [lemmatizer.lemmatize(word.lower(), to_wordnet_pos(tag))
for word, tag in nltk.pos_tag(tokens)]
Lowercasing before lemmatizing is common practice because WordNet entries are stored in lowercase, and capitalized forms may not match. The cost is that you lose the distinction between proper nouns and common words, so decide whether that matters before applying it.
Setup requirements
The lemmatizer needs the WordNet data, downloaded with nltk.download. Tokenizing and tagging need further resources, such as the Punkt tokenizer models and the averaged perceptron tagger. The exact resource names have changed between NLTK releases; some versions also require an Open Multilingual WordNet package or language-specific variants of the tokenizer and tagger. If you see a LookupError, its message names the missing resource. Check the documentation for your installed version rather than relying on a fixed list.
How lemmatization differs from stemming
NLTK also offers stemmers, such as the Porter and Snowball stemmers. These cut suffixes by rule, without a dictionary check. The difference shows up in both output quality and behavior.
| Aspect | WordNet lemmatizer | Porter or Snowball stemmer |
| Output | Valid dictionary word, or the input unchanged | Rule-based stem that may not be a real word (for example, "studies" to "studi") |
| Irregular forms | Handles listed exceptions such as "geese" to "goose" | Generally misses them |
| Part of speech | Needed for good results | Not used |
| Unknown words | Returned unchanged | Still trimmed by rules |
| Readability of output | High | Often low |
Stemming is simpler and needs no tagger or dictionary, which can be enough for rough search indexing. Lemmatization is the better choice when people will read the normalized words, or when merging unrelated words would distort the results.
Will the output stay readable and usable?
Lemmatized tokens are ordinary text characters, so they copy, paste, search and display like any other words. Unlike styled Unicode or mirrored text, there are no special code points to confuse screen readers or search engines.
The usability limits come from meaning, not encoding. A lemmatized sentence is a list of base forms with tense, number and agreement removed, and it doesn't read as natural prose. Several practical points follow:
- Keep the original text alongside the lemmas, because lemmatization cannot be reversed: "be" does not record whether the source said "is", "was" or "were".
- Don't show lemmatized text to readers in place of the original; use it as an internal index or analysis layer.
- Expect tagging errors to produce wrong lemmas, especially in short or informal text.
- Words missing from WordNet, such as many names, slang and newer terms, pass through unchanged, so the output mixes normalized and raw forms.
- If you lowercase before lemmatizing, keep a separate copy wherever capitalization carries meaning.
Evidence gaps
No benchmark data, accuracy figures or version-specific test results were available for this review. The behavior described here is based on NLTK's documented interface and on how WordNet lookup generally works. Before relying on the lemmatizer for a specific corpus, run a small sample through your installed version and check the output by hand, paying close attention to verbs, adjectives and domain-specific vocabulary.