liveBook · Manning

Tokenization

As explained in Natural Language Processing in Action, Second Edition

Tokenization is the process of dividing a character sequence into discrete lexical units such as words or punctuation.

Tokenization divides natural-language text into discrete units so computers can count, compare, search, classify, and represent documents numerically. A tokenizer turns an unstructured string into data suitable for an NLP pipeline. section 2.0

Tokenization can operate at several granularities:

  • Words, punctuation, emojis, emoticons, and logograms provide familiar, interpretable tokens. section 2.1
  • Word pieces, characters, and graphemes capture smaller units that can transfer patterns across related or unfamiliar words. section 2.2
  • Byte pair encoding, word-piece encoding, and sentence-piece encoding improve computational efficiency while making tokens less understandable to humans. section 2.2

Reducing false greeting matches

A tokenized intent recognizer can detect Hi or Hello without mistaking Hiking for Hi or Hell for Hello. This reduces false positives, although covering slang, misspellings, and typos still requires broader handling. section 2.5

Token counts support keyword detection, full-text search, information retrieval, sentiment classification, and document comparison. Token sequences can also become word vectors or one-hot encoded matrices, while normalization, stemming, and stop-word removal trade precision against recall and information loss. section 2.0 section 2.5 section 2.8

How Natural Language Processing in Action, Second Edition covers it

How deep it goes
Traces segmentation from documents to tokens, compares word and subword units, and reaches vectorization and preprocessing tradeoffs.
Examples
Uses greetings such as Hi and Hello, confusable strings such as Hiking and Hell, emojis, logograms, and subword encodings.
What it assumes
Assumes basic NLP pipeline context while defining segmentation, tokens, vocabulary, and numerical representation directly.
What you can do after
Apply it via a configured tokenizer to represent text, detect keywords, support search, and prepare tokens for numerical encoding.
How it connects
Connects tokenization to NLP pipelines, keyword detection, search, word vectors, one-hot encoding, stemming, lemmatization, and stop words.

Also explained in

Compare how 25 books explain tokenization →

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.