Skip to content

How It Works ​

Why So Small? ​

Suzume's WebAssembly binary, including its built-in dictionaries, is about 260KiB gzipped. Traditional analyzers often need tens of megabytes of dictionaries. How does Suzume keep its binary small?

The Short Answer ​

MeCab with an IPADIC-style dictionarySuzume
Loads a broad word list with morphological metadataStores selected words and exceptions
Loads a pre-computed connection-cost matrixComputes connections from compact rules
Uses dictionary entries plus unknown-word definitionsUses dictionary entries plus pattern-generated candidates

Key Insight

The dictionary selected for MeCab supplies its vocabulary, labels, and connection costs. Suzume instead keeps a smaller lexical set and generates additional candidates from character and grammar patterns. The exact MeCab setup used elsewhere in these docs is recorded in the comparison baseline.

The Three Pillars ​

How Suzume keeps its footprint small1Minimal dictionaryKeep function words,particles, and exceptions.2Grammar patternsInfer unknown words fromJapanese word structure.3Dynamic scoringCompute likely POSconnections at runtime.Small enough for frontend apps
Suzume keeps the shipped data small and moves more of the analysis into compact grammar and scoring code.

What is Tokenization?

Breaking text into meaningful units (tokens) and identifying their parts of speech. For Japanese, this means segmenting continuous text like "東京に行く" into "東京 / に / 行く".

1. Minimal Dictionary ​

Traditional analyzers store exhaustive word lists:

# MeCab dictionary entry (simplified)
東京,noun,proper,place,*,*,*,東京,トウキョウ,トーキョー,0/3,C1

Suzume stores high-frequency function words, particles, auxiliaries, and selected exceptions. For many content words, it relies on character patterns and grammar rules instead of shipping every possible surface form.

CategoryTraditional dictionary analyzerSuzume
Function wordsStored in the dictionaryCompact entries and grammar rules
Verbs and adjectivesMany surface/conjugated entriesConjugation rules plus selected exceptions
General and proper nounsBroad lexical coverageCharacter-pattern candidates plus a compact dictionary
Domain-specific termsDictionary package or customizationRuntime user dictionary

2. Pattern Recognition ​

Instead of storing every word, Suzume recognizes patterns:

Pattern recognition for unknown wordsスカイツリーIndictionary?NoKatakanasequence?YesGenerate noun candidateOther examples:Kanji sequence → noun candidateKanji + する → verbal noun / verb candidateHiragana + い → adjective candidate
For example, a katakana sequence that is not in the dictionary can still become a noun candidate.
PatternRuleResult
[カタカナ]+Generate a noun candidatenoun candidate
[漢字]+Generate a compound-noun candidatenoun candidate
[漢字]+するGenerate a verbal-noun constructionnoun + する (verb)
[ひらがな]+いEnding in い = adjective candidateadjective

Why This Works

Japanese character types and inflectional endings provide useful candidate signals. Suzume combines those signals with dictionary entries and surrounding connection scores; a pattern match alone does not guarantee the final POS or boundary.

Try it with your own text:

Try It In The Browser

Nothing is sent to a server. The Suzume WASM bundled with this page tokenizes, lemmatizes, and extracts tags locally.

Loading WASM...

3. Dynamic Connection Scoring ​

A MeCab dictionary such as IPADIC includes a pre-computed connection-cost matrix:

# Which word can follow which? (simplified)
noun → particle: cost 100
noun → verb: cost 500
particle → noun: cost 50
...millions of combinations

Suzume computes connection scores dynamically using compact rules:

Runtime connection scoringprevious tokennouncurrent tokenはnoun + は: connection bonusApply the connection bonus; Viterbichooses the lowest-cost full path.No massive matrix is shipped. The scoring rules are compact C++ code inside the WASM module.
Viterbi minimizes word and connection costs across the full path. A noun + は connection bonus can change the selected path.

Consistency of Analysis ​

Suzume decides parts of speech and boundaries from both dictionary entries and shared rules for character types, conjugation, and connections. Applying shared rules across many candidates reduces reliance on individually tuned lexical entries, although context and competing candidates can still change the result.

In a dictionary-and-cost-table design, entries with similar grammatical roles can still carry different labels or costs. Shared construction rules reduce that source of variation, while dictionary candidates and surrounding context continue to affect the selected path.

For example, "じゃ" is analyzed as the auxiliary lemma "だ" in "本じゃない", "本じゃなかった", and "本じゃな". The negative "ない" and "なかっ" in the first two examples are adjectives; the final "な" in the last example is a particle. The causative-passive rules likewise aim to normalize equivalent constructions while still resolving them in context (see the relevant sections in the MeCab comparison).

This consistency is separate from the question of which segmentation is "correct". It does not claim that Suzume's analysis is the only right one; it refers to the property that whichever rules are adopted are applied uniformly across inputs. The rules also have limits, and within those the classification can still vary (see Constraints).

Different Optimization Targets ​

Choose by purpose

Suzume is optimized for compact, search-friendly tokenization in browsers, edge runtimes, and native applications. A full dictionary analyzer is a different tool: choose one when its dictionary coverage and detailed morphological taxonomy are requirements. The outputs are not intended to be interchangeable, so a MeCab match rate is not Suzume's success metric. See When to Use Which for a full requirement-by-requirement comparison.

The dictionary, pattern-based candidate generation, and Viterbi scoring pipeline described here always runs. SuzumeOptions controls normalization and segmentation, dictionary loading, scorer configuration, and whether a JavaScript instance uses an isolated WASM runtime. See the API reference for the complete option set.

Tuning tokenization

mode: 'search' | 'split' and mergeCompounds let you adjust how aggressively compounds are segmented or merged for your use case. See the API reference for details.

Technical Deep Dive ​

What is a Lattice?

A graph structure representing all possible ways to segment text. Each path through the lattice is a potential tokenization. For "すもも", possible paths include "すもも" (plum) or "す/もも" (vinegar + peach).

What is Viterbi Algorithm?

A dynamic programming algorithm that finds the optimal path through the lattice. Instead of evaluating every possible combination, it efficiently finds the best segmentation by reusing previous calculations.

Analysis Pipeline ​

Analysis pipelineExample: 東京スカイツリーに行きました1Pre-tokenizeURLs, email, numbers2Candidatesdictionary + patterns3Latticeall possible paths4Viterbibest scoring path東京 / スカイツリー / に / 行き / まし / た
The analyzer keeps multiple possible segmentations alive until scoring selects the best path.

Unknown Word Handling ​

When Suzume encounters an unknown word like "スカイツリー":

  1. Not in dictionary — no stored entry
  2. Pattern match — recognized as katakana sequence
  3. Generate candidate — create noun hypothesis
  4. Compete in lattice — scored against other possibilities
  5. Select best — Viterbi finds optimal segmentation

Verb Conjugation ​

Suzume derives regular inflected forms from shared conjugation rules instead of requiring each form as a hand-authored lexical entry. Selected dictionary entries can still be expanded into materialized forms when dictionaries are compiled or loaded; see the user dictionary guide for the runtime case.

Base: 食べる (to eat)
├── 食べ + ない → negative
├── 食べ + ます → polite
├── 食べ + た → past
├── 食べ + て → te-form
└── 食べれ + ば → conditional

The rules generate regular forms, while selected dictionary entries may materialize their expanded forms at compile or load time.

Summary ​

QuestionAnswer
Why is the MeCab + IPADIC setup larger?IPADIC supplies a broad lexicon and pre-computed connection costs
Why is Suzume small?Stores rules + minimal dictionary
Are MeCab and Suzume outputs interchangeable?No. Their goals, boundaries, and POS taxonomies differ
When to use MeCab?When a MeCab dictionary's lexical coverage and analysis conventions are required
When to use Suzume?Compact search/display tokenization across browsers, server runtimes, Python, Go, and C/C++

See also ​