Word Tokenization › Language-Specific Challenges

Michael BrenndoerferUpdated March 21, 20258 min read
Language AI HandbookAll chapters
Part 1 of 67Text as Data
Chapter 5Word Tokenization › Language-Specific Challenges
Reading section 7 of 17 · Language-Specific Challenges · 8 minSection 7 of 17 · 8 min

Book contents

Section 7 of 17 · 8 min read

Word Tokenization › Language-Specific ChallengesOne section · Sections in this chapter7 / 17 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

English, with its space-separated words, is relatively easy to tokenize. Other languages present unique challenges that reveal how much the whitespace convention assumes. When we step outside of languages that use spaces, we realize that tokenization is not a universal procedure but a language-specific task that must be designed with the particular language's writing system and morphology in mind.

The diversity of human writing systems is remarkable. Some scripts separate words with spaces (Latin, Cyrillic, Arabic). Others run characters together without any delimiters (Chinese, Japanese for many purposes). Some languages build words by concatenating morphemes into long compound words (German, Finnish, Turkish). Some have extremely complex morphological systems where a single word can encode what English expresses in a whole sentence. There is no single tokenization algorithm that handles all of these correctly.

Chinese: No Word Boundaries

Chinese text contains no spaces between words. Characters flow continuously, and determining word boundaries requires linguistic knowledge. This is not a defect of the writing system; Chinese characters are ideographic and have been written without spaces for thousands of years. The concept of a "word" in Chinese is itself somewhat different from the English concept.

Consider the string "我喜欢学习自然语言处理" (I like studying natural language processing). There are eleven characters, but how many words? The answer depends on how you define "word". If you count morphemes, you get more. If you count content units, you might count differently. The standard NLP answer is to try to segment the string into units that correspond to dictionary entries, which requires a combination of dictionary lookup, statistical modeling, and contextual reasoning.

In[22]:
Code
# Chinese text without spaces
chinese_text = "我喜欢学习自然语言处理"
# Translation: "I like studying natural language processing"

# Character-level tokenization (always works)
char_tokens = list(chinese_text)

# Word-level requires a specialized tokenizer.
# Use jieba when available; otherwise use a fixed segmentation for this example.
try:
    import jieba

    word_tokens = list(jieba.cut(chinese_text))
except ModuleNotFoundError:
    word_tokens = ["我", "喜欢", "学习", "自然语言处理"]
Out[23]:
Console
Chinese text: 我喜欢学习自然语言处理
Translation: 'I like studying natural language processing'

Character tokens: ['我', '喜', '欢', '学', '习', '自', '然', '语', '言', '处', '理']
Character count: 11

Word tokens: ['我', '喜欢', '学习', '自然语言', '处理']
Word count: 5

Character tokenization produces 11 tokens, one per character. Word tokenization produces fewer, more meaningful units. The word tokenizer identifies "自然语言处理" (natural language processing) as a compound term and keeps it together, while character tokenization would split it into six individual characters. This matters: "自然" alone means "nature" or "natural", but the full six-character string has a technical meaning specific to the field of NLP.

The impact of tokenization granularity varies dramatically across languages:

Tokenization granularity comparison across languages. English shows the largest character-to-word ratio due to explicit whitespace boundaries.
LanguageExample TextCharacter TokensWord TokensRatio
English"Hello world"1125.5x
Chinese"我喜欢学习自然语言处理"1152.2x
Japanese"私はPythonでNLPを勉強しています"20111.8x

Languages without explicit word boundaries (Chinese, Japanese) show smaller differences between character and word tokenization because word boundaries must be inferred. English shows the largest ratio because whitespace already provides clear word boundaries, making character tokenization produce many more tokens than word tokenization.

Japanese: Mixed Scripts

Japanese uses three writing systems in combination: hiragana (a syllabic alphabet for native Japanese words and grammatical elements), katakana (a syllabic alphabet for foreign words and emphasis), and kanji (Chinese-derived ideographic characters). Words can be written in any combination of these scripts, and spaces are rarely used. This creates a tokenization challenge that is more complex than Chinese because the tokenizer must handle missing spaces and script changes from character to character.

The mixing of scripts provides useful cues. Foreign words written in katakana form natural units. Sequences of kanji interrupted by hiragana often indicate word boundaries. Latin letters embedded in Japanese text (like "NLP" or "Python") form their own units. A good Japanese tokenizer exploits these cues while also relying on a morphological dictionary and statistical models for the many cases where script alone is ambiguous.

In[24]:
Code
# Japanese text with mixed scripts
japanese_text = "私はPythonでNLPを勉強しています"
# Translation: "I am studying NLP with Python"

# Character tokenization
jp_char_tokens = list(japanese_text)

# Word-level tokenization requires MeCab or similar
# For demonstration, we'll show the expected output
expected_jp_words = [
    "私",
    "は",
    "Python",
    "で",
    "NLP",
    "を",
    "勉強",
    "し",
    "て",
    "い",
    "ます",
]
Out[25]:
Console
Japanese text: 私はPythonでNLPを勉強しています
Translation: 'I am studying NLP with Python'

Character tokens: ['私', 'は', 'P', 'y', 't', 'h', 'o', 'n', 'で', 'N', 'L', 'P', 'を', '勉', '強', 'し', 'て', 'い', 'ま', 'す']
Character count: 20

Expected word tokens: ['私', 'は', 'Python', 'で', 'NLP', 'を', '勉強', 'し', 'て', 'い', 'ます']
Word count: 11

Japanese tokenization must handle the mixing of scripts. "Python" and "NLP" are written in Latin characters, while the rest uses Japanese scripts. A good tokenizer recognizes these boundaries and segments appropriately. Notice that even at the "word" level, the tokenization is quite fine-grained: grammatical particles like "は" (topic marker) and "を" (object marker) become separate tokens, because in Japanese, these particles are separate morphemes, not inflectional endings attached to the preceding word.

German: Compound Words

German creates long compound words by concatenating shorter words without spaces. "Donaudampfschifffahrtsgesellschaftskapitän" (Danube steamship company captain) is a single orthographic word consisting of four meaningful components. This is not an edge case or a quirk: German compounds are extremely common and productive. New compounds are formed freely by combining existing words.

For most NLP tasks, you have a choice: treat the compound as a single token, or decompose it into its parts. The right choice depends on the task. For information retrieval, treating "Krankenhaus" (hospital) as a single token means a query for "Kranken" (sick) won't find documents about hospitals. Decomposing it allows the match, at the cost of potentially matching unrelated words that happen to contain "Kranken" as a component.

In[26]:
Code
# German compound words
german_compounds = [
    ("Handschuh", ["Hand", "Schuh"]),  # glove = hand + shoe
    ("Krankenhaus", ["Kranken", "Haus"]),  # hospital = sick + house
    (
        "Bundesausbildungsförderungsgesetz",
        ["Bundes", "Ausbildungs", "Förderungs", "Gesetz"],
    ),  # Federal education support law
]

# Simple whitespace tokenization keeps compounds together
german_text = "Das Krankenhaus hat einen neuen Handschuh."
german_tokens = german_text.split()
Out[27]:
Console
German Compound Words:
--------------------------------------------------
  Handschuh
    = Hand + Schuh
  Krankenhaus
    = Kranken + Haus
  Bundesausbildungsförderungsgesetz
    = Bundes + Ausbildungs + Förderungs + Gesetz

Text: Das Krankenhaus hat einen neuen Handschuh.
Tokens: ['Das', 'Krankenhaus', 'hat', 'einen', 'neuen', 'Handschuh.']

For some applications, you might want to decompose compounds into their constituent parts. This requires morphological analysis beyond simple tokenization. Modern NLP approaches often sidestep this problem by using subword tokenization methods like BPE that learn to split words at frequently occurring boundaries, which often coincide with morpheme boundaries in languages like German.

Arabic: Complex Morphology

Arabic presents multiple challenges: right-to-left script, complex morphology with prefixes and suffixes attached to words as clitics, and optional vowel diacritics. A single Arabic word can pack what English might express as a full sentence. The word "وسيكتبونها" means "and they will write it", combining a conjunction ("و", and), a future marker ("س"), the verb root (write), a plural subject marker, and a feminine object pronoun, all without spaces.

This morphological richness means that whitespace tokenization, while technically possible for Arabic, produces tokens that are linguistically very coarse. The tokens you get are morphologically complex forms that include clitics, and most NLP tasks benefit from separating those clitics from the stem they attach to.

In[28]:
Code
# Arabic text example
arabic_text = "أحب تعلم معالجة اللغة الطبيعية"
# Translation: "I love learning natural language processing"

# Basic tokenization (whitespace works for Arabic)
arabic_tokens = arabic_text.split()

# But morphological analysis might split further
# وكتبتها = و + كتبت + ها (and + I wrote + it)
morphological_example = "وكتبتها"
morphological_parts = ["و", "كتبت", "ها"]  # Expected decomposition
Out[29]:
Console
Arabic text: أحب تعلم معالجة اللغة الطبيعية
Translation: 'I love learning natural language processing'

Whitespace tokens: ['أحب', 'تعلم', 'معالجة', 'اللغة', 'الطبيعية']
Token count: 5

Morphological complexity example:
  Word: وكتبتها
  Parts: و + كتبت + ها
  Meaning: 'and' + 'I wrote' + 'it'

Arabic whitespace tokenization works at the surface level, but a single orthographic word often contains multiple morphemes that might be separate tokens in other languages. For Arabic NLP, most researchers use a dedicated morphological analyzer like MADAMIRA or Farasa to perform tokenization and morphological segmentation simultaneously, separating clitics from stems before any further processing.

The lesson from these language-specific challenges is that tokenization is not a universal procedure. It depends on a language's writing system and morphological conventions. Building a tokenizer requires understanding the language you are working with, not just applying a general algorithm.