Skip to content
uencoder

Tokenization

Tokenization splits text into a sequence of semantic units (words, subwords, characters); it is a foundational step in NLP and search engines.

Purpose

Turns continuous text into discrete token sequences for downstream processing and analysis.

Mechanism

English is split by whitespace and punctuation (abbreviations and hyphens need special handling). Chinese requires word-segmentation algorithms (maximum matching, statistical models such as HMM/CRF, deep models such as BERT). Subword tokenization (BPE, WordPiece) balances vocabulary size against coverage.

Use cases

  • Search engine index building
  • NLP preprocessing (BERT tokenization)
  • Lexical analysis in code analyzers
  • Variable parsing in template engines

Examples

  • Input
    I love NLP
    Output
    ["I","love","NLP"]

    Whitespace tokenization

Common errors

Processing Chinese as raw characters without segmentation
Use segmenters such as jieba/THULAC

Related terms

References