Token Normalization

Mapping tokens that differ superficially to the same index term. Equivalence classes, case folding, punctuation, accents and diacritics, Unicode normalization, and the choice between normalizing the index and expanding the query.

Token normalization merges tokens that should match into one index term, either as equivalence classes applied alike to documents and queries (cheap, symmetric, fixed at indexing time) or by asymmetric query expansion (more expressive, but only as complete as its table and paid on every query). Every merge trades precision for recall. On the 10,788 Reuters-21578 stories, case folding cuts the types from 60,203 to 49,530, 17.7 percent. Most of what it merges is position, as in oil, Oil, OIL; the harm sits in words such as Fed, May and US, and deleting periods then merges U.S with the pronoun us. Lowercasing is not Unicode case folding, and only the compatibility forms NFKC and NFKD merge ligatures and full-width characters.

When the architecture article processed the thesis student's four Arctic sentences, it lowercased them without comment, so the query arctic matched the capitalized Arctic of d1, d2, and d4. Real text makes that step less innocent. In the Reuters-21578 news stories, lowercasing merges oil, Oil, and OIL, which differ only because of sentence position and all-capital headlines. It also merges Fed, the Federal Reserve, with fed, the past tense of feed. A query usa should probably find U.S.A., and a query resume should find résumé. After tokenization, each of these pairs is two different strings, and an index that stores strings exactly treats them as different words. Which tokens should count as the same term, and what does each merge cost? No rule answers the first question for every pair, and the cost is always of one kind: each merge trades precision for recall.

Token normalization maps tokens that should match onto a single index term. It is where most decisions about what counts as "the same word" are made, apart from the more aggressive reductions of stemming. Merging U.S.A. and usa helps, but merging Windows and windows conflates an operating system with part of a house.

Here is the route. First we compare the two ways of implementing any normalization: equivalence classes in the index, and expansion of the query. Then we take the main kinds of variation in turn: case, punctuation inside tokens, accents, and the several Unicode encodings of one character. Finally we apply the rules one after another to the Reuters vocabulary and draw principles for choosing how far to go. Worked problems at the end include the course text's exercise on normalized forms. The article assumes the vocabulary of tokens, types, and terms from Tokenization.

Equivalence classes and asymmetric expansion

How can a system make two different tokens match? Manning, Raghavan, and Schütze (2008, §2.2.3) describe two ways.

The first creates equivalence classes. A normalization rule, such as "delete periods" or "convert to lowercase", is applied to every token in both documents and queries. All tokens that the rule maps to the same string fall into one class, and the index stores only that string. U.S.A. and USA both become usa, so either form in a query finds both forms in documents. The classes are implicit: nobody lists them, because they follow from the rules. This approach is simple and keeps the index small, but every class is symmetric. If Windows and windows are merged, a search for either finds both.

The second keeps distinctions in the index and expands the query instead. A table records, for each query term, which index terms it should match, and the relation need not be symmetric. Their example:

Query term Matches index terms
window window, windows
windows Windows, windows, window
Windows Windows

A user who types the capitalized Windows probably means the operating system, and gets only that. A user who types window or windows gets both the plural and the singular. Asymmetric expansion can express judgments that equivalence classes cannot, but it costs more in two ways:

  • the index is larger, because distinctions are kept;
  • each query term becomes several postings lists to merge.

The cost of expansion is paid on every query, whereas equivalence classing is paid once, at indexing time.

Five documents, two approaches

A five-document collection makes the difference concrete. The documents are:

  1. Windows crashed again
  2. clean the windows
  3. a window seat
  4. WINDOWS update failed
  5. the window of opportunity

Under case folding as an equivalence class, the index holds window (documents 3 and 5) and windows (documents 1, 2, and 4). Under asymmetric expansion, the index keeps the case of each token, and the table above decides which terms each query reads.

Example (one query, two answers). The query window retrieves only documents 3 and 5 under case folding, because the singular and the plural are different strings. Under expansion it retrieves documents 2, 3, and 5, because the table sends window to windows as well. The full comparison:

Query Asymmetric expansion Case-folded classes
window 2, 3, 5 3, 5
windows 1, 2, 3, 5 1, 2, 4
Windows 1 1, 2, 4

Expansion gives the query Windows the operating-system story alone, while case folding cannot tell it from the query windows. But expansion misses document 4. Its all-capital WINDOWS appears nowhere in the table, and an expansion table is only as complete as its entries. (The example is computed by tools/experiments/textproc/normalization.py.)

The two approaches can be combined, and most systems apply a few safe rules as equivalence classes, such as Unicode normalization and usually case folding. They handle riskier relations, such as synonyms, by query expansion, which can be changed without rebuilding the index.

The rest of the article takes the candidate rules one at a time, beginning with the most common, and asks of each whether it is safe enough to apply in the index.

Case folding

Case folding maps every letter to one case, usually lowercase. It is nearly universal in search, for a practical reason: people type queries in lowercase regardless of how the words are normally written. A user who types ferrari wants documents that say Ferrari.

Case sometimes carries meaning, and folding destroys it:

  • General Motors and general motors, Bush and bush, Apple and apple;
  • acronyms that coincide with words: MIT and mit (German for with), CAT (the company) and cat, US and us;
  • Fed (the Federal Reserve) and fed.

A heuristic alternative lowercases only words whose capitalization is probably due to position, such as words at the start of a sentence or in all-capital headings. It keeps mid-sentence capitals as evidence of a proper noun. Truecasing goes further, using a statistical model to predict each word's correct case from its context (Lita, Ittycheriah, Roukos, and Kambhatla, 2003). In practice, users rarely capitalize queries, so plain lowercasing usually serves them better than preserving case would (Manning, Raghavan, and Schütze, 2008, §2.2.3).

What case folding merges in Reuters

How much of what folding merges is harmless? Most of it, by the count of merged groups. Split into tokens by the Unicode word-boundary rules described in Tokenization, the 10,788 stories have 60,203 distinct types. Lowercasing them leaves 49,530, a reduction of 17.7 percent. The course text reports nearly the same proportion for the much larger Reuters-RCV1: case folding, applied after numbers have been removed, cuts 17 percent of its distinct terms and 3 percent of its nonpositional postings (Manning, Raghavan, and Schütze, 2008, §5.1, Table 5.1; from its counts, 473,723 to 391,523 terms and 100,680,242 to 96,969,056 postings, 17.4 and 3.7 percent). The 17.7 percent measured here includes the types that contain digits. Stop Words reproduces the table. That reduction comes from 8,232 groups of types that differ only in case. In 8,031 of those groups, every form has one of three shapes:

  • all lowercase, as in oil;
  • a capital first letter, as in Oil;
  • all capitals, as in OIL.

Sentence-initial capitals and Reuters' all-capital headlines produce exactly that pattern. So most of what folding merges is variation due to position.

The remaining risk is in words whose capitalized form is a different word. Counting occurrences in the collection:

Capitalized form Count Lowercase form Count Merge
OPEC 457 opec 6 harmless (also Opec, 56)
Fed 368 fed 14 harmful (also FED, 236)
May 1,030 may 865 mixed: the month and the verb
US 56 us 147 harmful
IT 198 it 8,747 mostly harmless here

The headline problem cuts both ways. IT in Reuters is almost always the pronoun in an all-capital headline, not information technology, so folding it is correct. But MAY, which occurs 233 times and nearly always in a headline, could be either the month or the verb.

Example (folding cannot be undone later). If the index folds case, no later stage, such as the ranking function, can still tell the month in a headline from the verb. After folding, the month, the verb, and the headline form are all the term may, and the index records nothing else about them. The counts come from tools/experiments/textproc/normalization.py. Merges like May and may are the case for the heuristic of folding only sentence-initial and headline capitals.

Lowercasing is not case folding

A natural assumption is that case folding means calling a lowercase function, but outside the unaccented Latin alphabet it does not. Unicode distinguishes lowercasing from case folding, which is designed for caseless matching (The Unicode Standard, section 5.18):

  • The German ß is already lowercase, so lowercasing Straße leaves it unchanged. Case folding maps it to strasse, so that it matches the capitalized spelling STRASSE.
  • Turkish has both a dotted and a dotless i, each with its own capital. The capital İ (dotted) lowercases to i with a combining dot, two code points, unless the software applies Turkish-specific rules. Default folding also maps the undotted capital I to the dotted i, where Turkish requires the dotless ı.

Search systems for such languages need language-aware folding.

The difference is visible at the level of code points. Python's lower() implements Unicode lowercasing and casefold() implements default case folding:

Input Code points lower() casefold()
Straße 53 74 72 61 DF 65 straße strasse
İstanbul 130 73 74 ... i̇stanbul, 9 code points (69 307 73 ...) i̇stanbul, the same
find FB01 6E 64 find (unchanged) find
ABC1 FF21 FF22 FF23 FF11 abc1 (still full-width) abc1

Code points are in hexadecimal without the U+ prefix. Case folding expands ß and also the fi ligature, but neither function turns full-width letters into ordinary ones. That is the job of the compatibility normalization described below, which is why pipelines apply normalization before folding.

Punctuation within tokens

Case is not the only difference between U.S.A. and usa. Tokenization decides where tokens end; normalization decides what to do with punctuation that remains inside them. Common rules delete periods in abbreviations (U.S.A. to usa, Ph.D. to phd). They also handle hyphens consistently, for example mapping anti-discriminatory and antidiscriminatory to one form. Each rule has exceptions:

  • numbers, such as 3.14;
  • version strings, such as 2.0;
  • identifiers in which punctuation is significant, such as C++ and .NET.

A system therefore usually applies punctuation rules only to tokens that look like words. Even then, a word-like abbreviation can collide with a word, as the Reuters measurements at the end of the article show.

Accents and diacritics

People often omit diacritics when they type, especially on keyboards that make them awkward. Removing them in the index lets resume match résumé, naive match naïve, and Universitat match Universität. The standard method uses Unicode decomposition. Each character is split into a base letter and combining marks, and the marks are deleted. Applied to Universität naïve résumé, it produces Universitat naive resume. Some letters, such as the Danish ø and the Polish ł, have no decomposition and need separate folding rules.

Removing diacritics conflates words that differ only in their marks, and in some languages those differences are lexical. Manning, Raghavan, and Schütze (2008, §2.2.3) note the Spanish peña ('cliff') and pena ('sorrow'). German readers often transliterate umlauts rather than dropping them, writing ae for ä. So Universitaet is as likely a query as Universitat. A good rule depends on how the users of a particular system actually type, which can be measured from query logs.

Decomposition assumes that each accented letter is stored in one known way. It is not, and that is the subject of the next section.

Unicode normalization

Unicode often provides more than one way to encode what is visibly the same text. é can be stored as the single code point U+00E9, or as the letter e followed by U+0301, a combining acute accent. The string résumé is six code points in the first form and eight in the second. The two look identical on screen, and they do not match as strings.

Unicode normalization forms, defined in Unicode Standard Annex #15, resolve this:

  • NFC (canonical composition) converts text to precomposed characters where they exist. It is the usual storage form.
  • NFD (canonical decomposition) separates base letters from combining marks. It is the form used for removing diacritics.
  • NFKC and NFKD additionally apply compatibility mappings, which merge characters that differ only in presentation. The ligature fi becomes fi, and full-width letters and digits common in East Asian text become ordinary ones (ABC1 becomes ABC1). Superscript digits become ordinary digits.

Example (which form makes what equal). Every one of the four forms makes the two spellings of résumé equal as strings, as long as both spellings get the same form: both composed forms give six code points, and both decomposed forms give eight. NFC leaves find alone. The ligature is a compatibility character, not a canonical variant, so only NFKC and NFKD turn it into find.

The four forms applied to a few strings show what each one does. The numbers are lengths in code points:

Input As stored NFC NFD NFKC NFKD
résumé, precomposed 6 résumé, 6 8 résumé, 6 8
résumé, combining accents 8 résumé, 6 8 résumé, 6 8
Ångström, with U+212B 8 Ångström (U+00C5), 8 10 Ångström (U+00C5), 8 10
find 3 find, 3 3 find, 4 4
ABC1 4 ABC1, 4 4 ABC1, 4 4
x² 2 x², 2 2 x2, 2 2

The Ångström row shows a quieter case. Unicode has a separate code point, U+212B ANGSTROM SIGN, that is canonically equivalent to the letter Å (U+00C5), so even NFC replaces it. The last three rows change only under the compatibility forms. (Computed with Python's unicodedata module in tools/experiments/textproc/normalization.py.)

Many indexing pipelines apply NFKC, often combined with case folding, as an early normalization step. Lucene's ICU normalization filter, for example, by default combines NFKC normalization with case folding (Apache Software Foundation, Lucene 10 documentation for ICUNormalizer2Filter). Compatibility mappings do discard some distinctions, such as a superscript ² in mathematical text, so a system that needs them indexes NFC text instead. Without NFKC, two common sources of text silently fail to match ordinary queries: PDFs, where ligatures are common, and East Asian sources, where full-width forms are common. The delineation article describes where these characters come from.

Other variation

Several further kinds of variation are usually handled by normalization or expansion:

  • Spelling variants: British and American spellings (colour, color; organise, organize) can be merged by rules or by a variant table.
  • Transliterations: names written in another script have several spellings in the Latin alphabet (Chebyshev, Tchebycheff). These are hard to reduce by rules. Phonetic matching and variant lists are the usual tools.
  • Numbers and dates: recognizing March 20, 1991, 3/20/91, and 1991-03-20 as one date, and indexing it in a standard form, requires parsing rather than character substitution. It also requires a locale convention, since 03/04/91 is March 4 in the United States and 3 April in much of Europe. Done reliably, it makes the forms interchangeable in queries and supports date-range search.
  • Synonyms: car and automobile are different words with one meaning. Merging them in the index is rarely wise, since synonymy depends on context. Thesaurus-based query expansion is the usual approach, discussed with query expansion.

Choosing how far to normalize

Every rule in this article increases recall and risks precision. The right set depends on the collection, the languages, and how users write queries. How much each rule merges also depends on the collection. The figure applies the rules one after another to the Reuters tokens.

Example (two rules that change nothing here). NFKC and diacritic removal leave the size of the Reuters vocabulary unchanged. The collection contains a single non-ASCII character, a stray ü inside the token growth.üside. NFKC does not alter it, and removing its diaeresis changes that one type into growth.uside, which merges with no other. With no other accents to remove and no compatibility characters to map, the count of types stays the same through both steps:

Distinct terms in Reuters-21578 as normalization rules are added one after another, with the percentage change at each step. Notice the two flat steps: NFKC and diacritic removal leave the count unchanged, because the collection is ASCII apart from a single ü. Case folding removes 17.7 percent of the vocabulary and deleting periods and apostrophes a further 6.1 percent. Porter stemming, shown hatched for comparison, removes another 18.5 percent, about as much as case folding.
Distinct terms in Reuters-21578 as normalization rules are added one after another, with the percentage change at each step. Notice the two flat steps: NFKC and diacritic removal leave the count unchanged, because the collection is ASCII apart from a single ü. Case folding removes 17.7 percent of the vocabulary and deleting periods and apostrophes a further 6.1 percent. Porter stemming, shown hatched for comparison, removes another 18.5 percent, about as much as case folding.

The two flat steps are a property of this collection, not of the rules. On text extracted from PDFs, or on any collection in a language other than English, the same two steps merge many types.

Deleting periods and apostrophes after case folding is the riskiest step in the sequence. It does merge true variants, but it also makes two harmful merges:

  • It turns U.S into us, the same term as the pronoun us (147 occurrences) and the capitalized US (56). The tokenizer keeps the inner period of U.S. and drops the final one, so the form U.S occurs 5,675 times.
  • It turns it's into its.

Three principles help:

  1. Apply equivalence-class rules identically to documents and queries. An equivalence class exists only if both sides are mapped to the same term.
  2. Keep irreversible choices conservative. A distinction removed from the index cannot be restored at query time, while query expansion can be revised at any time. Rules that merge things that should rarely be merged are better handled at query time. Examples are case for acronyms, and diacritics in languages where they are lexical.
  3. Measure. Query logs show how people type, and an evaluation collection shows whether a rule helps. The methods of evaluation apply to normalization rules as much as to ranking functions.

Worked problems

The first problem is Exercise 2.2 of the course text (Manning, Raghavan, and Schütze, 2008, §2.2). The other three are posed on this article's own examples. Every result is computed by tools/experiments/textproc/normalization.py, which uses the tokenizers of Tokenization.

Problem 1 (Exercise 2.2: normalized forms). Suggest a normalized form for each of 'Cos, Shi'ite, cont'd, Hawai'i and O'Rourke, with the word itself allowed as an answer.

Solution. The exercise asks for a judgment, so the answer is a recommendation with its reasons. The rule sequence of this article (case folding, then deleting periods and apostrophes) gives one consistent answer: cos, shiite, contd, hawaii and orourke. The table sets it beside what three tokenizers do with the same strings.

Word Fold and delete the apostrophe This site's search UAX #29 NLTK
'Cos cos cos Cos 'Cos
Shi'ite shiite shi ite Shi'ite Shi'ite
cont'd contd cont d cont'd cont 'd
Hawai'i hawaii hawai i Hawai'i Hawai ' i
O'Rourke orourke o rourke O'Rourke O'Rourke

The NLTK column is from version 3.9.1. The tokenizer's treatment of apostrophes is not stable across versions: version 3.10.4 gives ' Cos for the first word and leaves Hawai'i whole. That instability is itself an argument for normalizing these forms by an explicit rule.

The reasons, word by word:

  • Shi'ite and Hawai'i are each also written without the apostrophe, as Shiite and Hawaii. Deleting the apostrophe maps both spellings of each to one term, shiite and hawaii, which is what a searcher typing either spelling needs. Splitting at the apostrophe does not: shi ite and hawai i match neither Shiite nor Hawaii.
  • O'Rourke is normally written with its apostrophe, but a searcher may type the name without it. The form orourke matches the queries O'Rourke and ORourke. The split form o rourke matches O'Rourke and O Rourke, and it lets the name match a bare Rourke. Either is defensible if documents and queries are treated alike. orourke is the more precise.
  • cont'd abbreviates continued. Deleting the apostrophe gives contd, which matches the other common abbreviation contd. and does not match continued. Mapping it to continued needs a table of abbreviations, which is asymmetric expansion and not a normalization rule.
  • 'Cos is an informal because. Folding gives cos, and so do two of the three tokenizers after lowercasing. That term collides with the abbreviation of cosine and with the island of Cos. Keeping the leading apostrophe, as this version of NLTK does, avoids the collision and then misses the spelling cos, which is the same word. The suggested form is cos, with the collision accepted as the price.

No single rule is clearly right for all five. Shi'ite and Hawai'i argue for deleting apostrophes, and the same rule turns it's into its, one of the two harmful merges found on Reuters above.

Problem 2 (repairing the expansion table). In the five-document collection, the expansion table missed document 4, WINDOWS update failed. Extend the table so that a search for the operating system finds it. Give the documents each of the three queries then retrieves and the number of postings lists each query reads.

Solution. The index keeps case, so WINDOWS is an index term of its own, with the postings list 4. An all-capital form can stand for the operating system or for the plural in a headline, so it is added to the rows of both Windows and windows, and not to the row of window:

Query term Matches index terms Documents Lists read
window window, windows 2, 3, 5 2
windows Windows, windows, window, WINDOWS 1, 2, 3, 4, 5 4
Windows Windows, WINDOWS 1, 4 2

The query Windows now retrieves both operating-system stories and still excludes the three documents about panes and seats. The query windows retrieves the whole collection. The repair costs one more postings list on two of the three queries, and it had to be made by hand: the table was complete only for the forms someone thought of.

Problem 3 (one word stored four ways). A collection stores the word fiancé in four ways: fiancé with the ligature U+FB01 and a precomposed é; the same with e followed by the combining accent U+0301; FIANCÉ in capitals; and the unaccented fiance. Give the length of each in code points under the four normalization forms. Find how many distinct strings remain after lowercasing, after case folding, after NFKC followed by case folding, and after this article's full sequence.

Solution. The ligature is one code point, and only the compatibility forms split it into f and i. The accented letter is one code point when composed and two when decomposed.

Stored form As stored NFC NFD NFKC NFKD
fiancé, precomposed é 5 5 6 6 7
fiancé, combining accent 6 5 6 6 7
FIANCÉ 6 6 7 6 7
fiance 6 6 6 6 6
  • Lowercasing leaves four distinct strings. It changes only the capitals, and fiancé from the third form still differs from the two ligature forms and from fiance.
  • Case folding leaves three. It expands the ligature, so the first and third forms both become the six code points of fiancé with a precomposed é. The second form keeps its combining accent and is a different string of seven code points.
  • NFKC followed by case folding leaves two: the three accented forms are now one string, and fiance is the other.
  • The full sequence (NFKD, remove the combining marks, case-fold) leaves one, fiance.

Each step merges what the one before could not, and the last merge is the one with a cost: in French fiancé and the verb form fiance are different words.

Problem 4 (nine types through two rules). Apply case folding, and then the deletion of periods and apostrophes, to the nine types U.S.A., USA, usa, U.S, us, US, it's, its and Its. Give the classes after each rule and say which merges are harmful.

Solution. Case folding leaves six classes: u.s.a., usa (from USA and usa), u.s, us (from us and US), it's, and its (from its and Its). The merge of US with us is harmful, since one is the country and the other the pronoun. The other two merges join forms of one word.

Deleting periods and apostrophes leaves three classes: usa (now also from U.S.A.), us (now also from U.S), and its (now also from it's). The merge of U.S.A. with USA is the one the rule is meant for. The merge of U.S with the pronoun is harmful, and it is the larger of the two country merges on Reuters, where U.S occurs 5,675 times. The merge of it's with its joins a contraction to a possessive.

Nine types have become three terms. One of the three, usa, holds only forms of one word.

What we have learned

Normalization decides which tokens become one term, and each decision trades precision for recall. Equivalence classes are cheap and fixed at indexing time. Asymmetric expansion is more expressive, but only as complete as its table, and it costs something on every query. On Reuters, case folding removes 17.7 percent of the types. Most of what it merges is the harmless oil, Oil, OIL pattern, and the harm sits in a few words such as Fed, May, and U.S. Unicode normalization and diacritic removal leave the vocabulary size unchanged on this collection, which is ASCII apart from one character, and change a great deal on text from PDFs or other languages.

Every rule so far compares whole words. Connected, connecting, and connection remain three terms, though a searcher would usually accept any of them. The next article, Stemming and Lemmatization, treats the removal of word endings. It compares stemming with lemmatization, measures the errors of the main stemmers on the Reuters vocabulary, and reports what retrieval experiments show about when the reduction helps.

References

Reviewed: verified, 16 Nov 2026 · checked against sources, 23 Nov 2026 · citations checked, 16 Nov 2026 · editorial review, 23 Nov 2026 · 8 revisions