Language Diversity, Typology, and Scripts › The Substrate: Scripts and Writing Systems

Michael BrenndoerferNovember 26, 20267 min read
Language AI HandbookAll chapters
Part 26 of 67Multilingual Language Models and Cross-Lingual Transfer
Chapter 183Language Diversity, Typology, and Scripts › The Substrate: Scripts and Writing Systems
Reading section 3 of 13 · The Substrate: Scripts and Writing Systems · 7 minSection 3 of 13 · 7 min

Section 3 of 13 · 7 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

For byte input, decode according to the declared encoding before applying text operations. Part I, Ch 1: Character Encoding introduces UTF-8, which represents Unicode scalar values as sequences of bytes. Unicode assigns codepoints and properties to encoded characters. Script properties and named codepoint blocks serve different purposes. A later example counts assigned values inside selected ranges. RFC 3629

A codepoint is a value in the Unicode codespace from 0 through 0x10FFFF. The surrogate range is excluded from Unicode scalar values. A visible text unit can span multiple codepoints, such as a Latin base letter with a combining accent or the Devanagari conjunct shown below. Count codepoints, grapheme clusters, and tokens separately.

Terminology: Grapheme vs. Codepoint vs. Character vs. Glyph
  • A codepoint is a single integer in Unicode.
  • A character is an informal term. Python's len(s) counts Unicode codepoints. Some string APIs instead count UTF-16 code units.
  • A default extended grapheme cluster is a text segmentation unit defined by Unicode Standard Annex #29. It can include combining marks, a sequence of conjoining Hangul jamo, or other multi-codepoint sequences.
  • A glyph is a visual form chosen during text rendering. Shaping can map codepoints to one or several glyphs depending on the font, surrounding text, and layout rules.

The Devanagari greeting “नमस्ते” (namaste) has six codepoints. In the pinned grapheme fixture, the final cluster is स्ते. Python’s len(s) counts codepoints. Report that unit separately from the grapheme count and any tokenizer result.

Script Typology

Writing systems differ in the units their signs represent. In an alphabet, letters typically represent consonants and vowels. Other systems may represent syllables or combine sound and meaning cues. These differences affect the input repertoire. Encoding length depends on which symbols occur and on how the tokenizer represents them.

The main types are:

  • Alphabets. Letters typically represent consonants and vowels. Use the target orthography when interpreting letter-to-sound patterns.
  • Abjads. Consonants form the main written sequence. For a vowel-mark probe, compare ب with بَ. The second string adds a sign, so a tokenizer or search pipeline can receive two different inputs.
  • Abugidas. In Devanagari, a consonant letter has an inherent vowel that an attached sign can modify. Compare क, कि, and कु. The second and third strings each add a vowel sign to the same base. Count their encoded lengths under the tokenizer you use.
  • Syllabaries and mora-based systems. Japanese kana represent morae, including the syllable-final nasal. Check how the tokenizer groups the written signs. Tokyo University of Foreign Studies
  • Morpheme-based writing. Japanese writing uses Han characters. The Agency for Cultural Affairs counts 2,136 character categories in the jōyō list. Compare the characters observed in your corpus with the vocabulary and fallback behavior of your tokenizer. Agency for Cultural Affairs jōyō FAQ, Q6
  • Hangul. Letters combine into written syllable blocks. Unicode encodes 11,172 modern precomposed Hangul syllables, with equivalent sequences of two or three conjoining jamo. Measure both forms under the tokenizer you use.

These differences give you three checks for a tokenizer:

  • Character coverage. Compare which characters occur in the target corpus with which characters the tokenizer represents directly. A codepoint inventory alone does not tell you how often the model uses fallback.
  • Combining sequences. Inspect boundaries on conjuncts and other multi-codepoint grapheme clusters. A learned tokenizer may split one grapheme across several tokens.
  • Multi-character pieces. Check whether the vocabulary includes common sequences as single pieces. The answer depends on the training text and vocabulary, even when two tokenizers start from the same characters.

Directionality

Test horizontal direction and vertical layout separately. Store characters in logical order for text operations.

  • Left-to-right. Start with the Latin string abc as a left-to-right display test.
  • Right-to-left. Include a mixed-direction probe containing Arabic text and a Latin product name. Test the order of both runs.
  • Vertical. Traditional Chinese and Japanese columns commonly proceed from right to left. Traditional vertical Mongolian columns proceed from left to right. Chinese layout · Japanese layout · Mongolian layout
  • Alternating direction. Boustrophedon names a layout that alternates direction from line to line. For an OCR task, record the reading order used by the source page.

For NLP, RTL scripts create two problems:

  1. Bidirectional text. For a mixed Arabic and Latin input, compare the displayed runs with the stored logical string. Inspect both if an annotator or OCR system returns text in an unexpected order.
  2. Sentence and token order. Decode and tokenize in the stored logical order. A display can reorder the visible text according to the Unicode Bidirectional Algorithm. Slicing or reversing the logical string to imitate its appearance can change the text that reaches the tokenizer.

Case, Spaces, and Punctuation

Test case mapping, whitespace boundaries, and punctuation separately in the preprocessing pipeline.

Case. German Straße lowercases to straße, and ẞ maps to ß. Turkish uses a locale-specific mapping for İ. Compare the locale rules in the Unicode data and test the exact implementation used in production. Unicode case mapping

Spaces. Whitespace splitting returns a single span for 我爱你. Compare an explicit word segmentation with the subwords produced by a tokenizer. Tokenization Challenges

Punctuation. Include the Chinese full stop 。, fullwidth comma ,, and quotation forms such as 「」 and “” in splitter tests. Add strings with Arabic ،, Spanish ¿, and Hebrew ״. Compare boundaries against the annotation convention you intend to use. Chinese text layout

A splitter whose only separator is '. ' leaves an input with no such separator intact. Test it on a mixed-punctuation example before relying on it for sentence boundaries.

Grapheme Clusters and Normalization

Earlier chapters dealt with Unicode normalization in depth (Part I, Ch 2: Text Normalization). For a multilingual chapter, the essential facts are:

  • Canonically equivalent strings. "é" can be one codepoint (U+00E9) or two ("e" + combining acute, U+0065 U+0301). Unicode normalization form C (NFC) composes; form D (NFD) decomposes. Two strings that look identical to a human can compare unequal as byte sequences, which is a trap for any exact-match evaluation.
  • Apply a consistent normalization policy. Compare the output of the training and inference transformations on the same input. Decomposition can change the codepoint sequence supplied to a tokenizer even when the normalized text remains canonically equivalent.
  • Hangul is a special case. The 11,172 precomposed syllable blocks in Unicode decompose into 2-3 jamo (U+1100-U+11FF). The two representations give different codepoint counts. Their effect on token counts depends on the tokenizer and whether it normalizes first.

A simple demonstration: the Vietnamese "ế" (U+1EBF) is one codepoint. The Hindi "क्ष" is क + ् + ष (3 codepoints, one grapheme). The Arabic "مَرْحَبًا" contains nine codepoints and five default extended grapheme clusters. The executable example below counts clusters and codepoints separately.

Complex Text Layout

Complex text layout (CTL) includes context-dependent shaping and the placement of marks. Arabic forms depend on joining context. In the Devanagari string कि, the stored consonant precedes the vowel sign. Inspect the glyph layout separately from the codepoint sequence.

For NLP this matters mostly in two places:

  1. OCR and transcription: test an Arabic recognizer on real pages with joined letters. Compare its output with the logical text and inspect errors against the page image.
  2. Evaluation. If exact-match scoring should treat canonically equivalent strings as equal, normalize both strings to the same canonical form before comparing them. Arabic lam and alef (U+0644 U+0627) may render like the compatibility presentation form U+FEFB. NFC and NFD preserve this distinction. Use NFKC when the evaluation should also equate compatibility forms such as these.

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy