Word Tokenization
Before anything can count words, something has to decide where one word stops and the next begins. Word tokenization is that decision: splitting a run of characters into the word-level units — tokens — that every later step treats as atomic.
Harder than splitting on spaces
Whitespace gets you most of the way in English and then abandons you. A tokeniser has to rule on:
- contractions — is don't one token, or do plus n't?
- punctuation — the dot in Dr. Smith ends neither a sentence nor a token;
- hyphens and compounds — state-of-the-art, e-mail;
- URLs, prices, hashtags and emoji, each of which a naive split shreds.
These are conventions rather than truths, which is why the Penn Treebank rules, NLTK's word_tokenize and spaCy's tokeniser disagree about the same sentence. Languages written without spaces — Chinese, Japanese, Thai — need word segmentation as a model in its own right, and morphologically rich languages pack into one word what English spreads over several.
Why the first step fixes the last
The token list defines the vocabulary, so it bounds what every downstream component can possibly see. Split U.S. into three tokens and a named-entity recogniser can no longer label it. Count don't and dont separately and one signal arrives as two columns of your TF-IDF matrix. Tokenise differently at training and serving time and the model receives strings it never learned. Word tokenisation also carries one unavoidable flaw: every token must already be in the vocabulary, so anything new arrives as OOV — the pressure that pushed modern models onto subword schemes.
Word tokenization splits text into word-level tokens, the units every later stage treats as atomic. Whitespace alone is insufficient: contractions, punctuation, hyphens, URLs and languages written without spaces all need explicit rules, which is why Treebank conventions, NLTK and spaCy tokenise the same sentence differently. The resulting token list defines the vocabulary and so bounds what any downstream model can see, and any word outside it arrives as OOV.
When you read a sentence you break it into words without a thought. A computer is handed one long ribbon of characters and has to be told where to cut.
Word tokenization is that cutting. Spaces get you started, but they settle surprisingly little. Is don't one word or two? Does the dot after Dr. end the sentence? What about state-of-the-art, or a web address, or Chinese, which is written with no spaces at all?
The cuts matter because everything that happens next counts the pieces. Cut badly and the software sees two different words where you wrote one, or half a word where you wrote a whole one, and that small mistake quietly follows it the rest of the way.