Tokenization, stemming and lemmatization
How tokenization, stemming and lemmatization change text, where each fits in a preprocessing pipeline, and when original text should be kept or shown.
Tokenization, stemming and lemmatization are three common steps in preparing text for search, analysis or machine learning. They are often grouped together, but they do different jobs and change text in different ways. This review explains what each step does, where it helps, what it costs in meaning and readability, and when the original plain text should be kept alongside the processed version.
Short answer: which step suits which use
Tokenization is almost always needed, because most text processing works on units such as words, punctuation marks or subword pieces rather than on one long string. Stemming and lemmatization are optional normalization steps that reduce different word forms to a shared form so that, for example, "connect", "connected" and "connecting" can be treated as related.
- Use tokenization for nearly any pipeline: search indexing, word counts, tagging, parsing or feeding a language model.
- Use stemming when you want broad matching and speed matter more than linguistic accuracy, such as recall-oriented keyword search.
- Use lemmatization when the normalized form must be a real dictionary word or when grammatical distinctions matter, such as linguistic analysis, readable keyword reports or features that people will inspect.
- Skip both stemming and lemmatization when exact wording carries meaning, when you need to display or quote text, or when a downstream model was trained on unnormalized text and handles word forms itself.
The decisive tradeoff is between matching and meaning. Stemming merges more forms with less effort but can merge unrelated words and produce fragments that are not words. Lemmatization is more precise and produces readable forms, but it depends on language resources and usually on knowing each word's part of speech. Neither step is reversible, so the original text should be retained whenever it might be needed again.
What each step actually changes
Tokenization: splitting text into units
Tokenization divides a string into tokens. It does not need to change any characters; in many implementations each token can be mapped back to a span of the original text. What changes is the structure: downstream steps now see a sequence of separate units instead of one string.
The rules for what counts as a token vary. A simple tokenizer may split on whitespace and punctuation. Others apply conventions such as splitting the contraction "don't" into "do" and "n't", keeping "U.S." or an email-like string together, or separating a trailing comma from a word. Language models typically use subword tokenization, where a rare word may be broken into several smaller pieces that the model has a vocabulary entry for. These are different definitions of a token, so token counts from one tool are not comparable with counts from another.
Several cases need particular care. Languages written without spaces between words, such as Chinese, Japanese and Thai, require a segmentation method rather than whitespace splitting. Hyphenated words, numbers with separators, URLs and hashtags can be split or kept whole depending on the rules. A tokenizer that splits text by individual Unicode code points can also break characters that readers perceive as one unit: a letter followed by a combining accent mark, or an emoji built from several code points joined together, such as a family or flag emoji. A tokenizer intended for user-facing text should treat these as single units, often called grapheme clusters.
Stemming: cutting words down by rule
Stemming removes or rewrites word endings using rules, without consulting a dictionary or the word's role in the sentence. The result, the stem, is a key for grouping words, not necessarily a real word. This is a stored character change: the token's text is replaced with a shorter string.
Rule-based stemming has two characteristic errors. Overstemming merges words with different meanings, such as "university" and "universe", which a widely used English stemmer reduces to the same stem. Understemming fails to merge words that are related, typically irregular forms such as "ran" and "run" or "mice" and "mouse", because no suffix rule connects them.
Lemmatization: mapping words to dictionary forms
Lemmatization replaces each word with its lemma, the form you would look up in a dictionary. It uses vocabulary and morphological analysis, so it can handle irregular forms: "was" becomes "be", "mice" becomes "mouse", and "better" used as an adjective becomes "good". Like stemming, it is a stored change to the token's text, but the output is meant to be a real word.
Accurate lemmatization usually depends on part-of-speech information. "Meeting" as a noun stays "meeting", while "meeting" as a verb becomes "meet". If a lemmatizer is not given the part of speech, it may apply a default that is wrong for many words. Lemmatizers are also language-specific, and quality depends on the resources available for that language.
Illustrative comparison
The example below shows the kind of output each step typically produces for a short English sentence. It is illustrative rather than a test result: exact output depends on the tool, its version, its language settings and whether part-of-speech tags are supplied.
Input: The studies weren't running as planned.
Tokens: The | studies | were | n't | running | as | planned | .
Stems: the | studi | were | n't | run | as | plan | .
Lemmas: the | study | be | not | run | as | plan | .
(lemmas assume correct part-of-speech tags)
Two points stand out. The stem "studi" is a matching key, not a word a reader would recognize. The lemma "be" for "were" requires knowing the irregular verb, something suffix rules cannot do. Whether a tool lowercases "The" or maps "n't" to "not" is a separate configuration choice, not an inherent part of stemming or lemmatization.
Tokenization versus lemmatization
These steps are not alternatives. Tokenization decides where words begin and end; lemmatization decides what base form each word maps to. Lemmatization needs tokens as input, so tokenization comes first, and tokenization errors carry forward. If a tokenizer splits a word in the wrong place, the lemmatizer receives a fragment it cannot analyze correctly.
| Aspect | Tokenization | Stemming | Lemmatization |
| Main job | Split text into units | Reduce words to a shared stem by rule | Map words to dictionary forms |
| Changes characters | Not necessarily | Yes | Yes |
| Output is a real word | Tokens are original text or subword pieces | Often not | Intended to be |
| Needs dictionary or part of speech | No for simple methods | No | Usually yes |
| Handles irregular forms | Not applicable | Poorly | Better, if the resource covers them |
| Reversible | Yes, if spans are kept | No | No |
Readability and usability of the processed text
Processed tokens are working data, not text for readers. Stems in particular can be unreadable, and even lemmatized text reads unnaturally because tense, number and agreement have been removed. If processed output is copied into a report, interface or message, readers may misunderstand it, and screen readers will announce stems such as "studi" or "univers" as they are spelled rather than as the intended word. Whenever text is shown to people, show the original wording; use the normalized forms only behind the scenes for matching, counting or grouping.
Practical safeguards for keeping processed text usable:
- Store the original text and, where possible, character offsets for each token, so results can be traced back and highlighted in context.
- Apply the same tokenizer, stemmer or lemmatizer, with the same settings, to both indexed documents and search queries; mismatched processing causes missed matches.
- When displaying grouped results, label each group with a representative original word rather than the stem.
- Record which tool, version and language settings produced the output, since different configurations give different tokens and forms.
- Check how your pipeline handles accented letters, combining marks, emoji and non-Latin scripts before relying on it for multilingual or user-generated text.
In search, both stemming and lemmatization generally make it easier to find documents that use a different form of the query word, at the cost of some unwanted matches. Stemming tends to cast a wider net because it merges more aggressively, including some unrelated words. Whether that tradeoff is acceptable depends on whether missing a relevant result or showing an irrelevant one is worse for your users.
When plain, unnormalized text is the better choice
- Quotations, legal or technical wording, and any text where the exact form of a word matters.
- Tasks that depend on grammatical detail, such as detecting tense, plurality or negation.
- Names, product codes and identifiers, which stemming can damage and lemmatizers may not recognize.
- Input to modern language models, which use their own subword tokenizers and are generally trained on unnormalized text; applying stemming first can remove information the model would otherwise use.
- Any output intended for human readers or assistive technology.
Evidence gaps
This overview describes how these techniques generally work. No specific tool was tested for it, and no benchmark figures, speed comparisons or accuracy rates were available, so none are given. Behavior differs between libraries, versions and languages, and the example outputs above should be confirmed by running your own sample text through the exact tools and settings you plan to use. Privacy and data handling were not assessed for any tool; if you process text through an online service, review that service's own documentation rather than assuming how it treats your data.