While organizing Japanese dictionaries, I gradually became interested in tokenization.
A dictionary usually stores a word in its dictionary form, while an article may contain many inflected forms. For example, when a sentence contains 「書かなかった」, a lookup system ultimately needs to find 「書く」. To do that, software first has to work out which words make up the sentence, then identify each word’s part of speech, dictionary form, and reading. Even a carefully prepared dictionary can be difficult to use if this first step goes wrong.
I wrote earlier about why Japanese dictionaries can still be difficult to use while reading. That article grew out of practical reading problems and the work of organizing Japanese dictionary data. Following the same line of curiosity, I began to wonder whether I could build a Japanese tokenizer of my own.
Back in 2019, I also published a Chinese-language article, 《日语分词器的介绍与比较》, introducing the Japanese tokenizers and dictionaries that were common at the time. Revisiting the subject seven years later, I found plenty more to learn. One question deserves a closer look: if I build a tokenizer, how can I tell whether it is actually doing a good job?
What Japanese tokenization does
Japanese writing generally does not put spaces between words in the way English does. Consider this sentence:
「今日は東京へ行く。」
The program receives one continuous sequence of characters and has to decide where the word boundaries belong. One possible result is:
今日 / は / 東京 / へ / 行く / 。
This process is commonly called tokenization. In Japanese natural language processing, the broader term is 「形態素解析」 (morphological analysis). It usually goes beyond finding word boundaries: it can also assign parts of speech, dictionary forms, and readings.
There is an important complication: Japanese word boundaries do not always have a single universally accepted answer.
Take 「選挙管理委員会」. Sudachi’s documentation uses this expression to demonstrate three segmentation granularities:
選挙 / 管理 / 委員 / 会選挙 / 管理 / 委員会選挙管理委員会
Each result treats the expression as units of a different size. Sudachi allows applications to choose the granularity that suits their needs. Vocabulary analysis may benefit from smaller units, while search or named-entity handling may benefit from preserving a larger compound.
That is why an evaluation needs a clearly defined segmentation standard. If two systems use different standards, their outputs can differ even when both are behaving as designed.
The Japanese tokenizer ecosystem
Japanese morphological analysis has been developed for many years, and a mature ecosystem of analyzers and dictionaries has grown around it.
MeCab is one of the classic Japanese morphological analyzers. It is commonly paired with dictionaries such as IPADIC and UniDic. IPADIC has been widely used for a long time. UniDic is closely connected to the annotation conventions developed by the 国立国語研究所 (National Institute for Japanese Language and Linguistics), and uses Short Unit Words as its basic units. MeCab builds a lattice from dictionary candidates, then uses a statistical model to score the possible combinations and select a low-cost path. It is useful to keep the roles separate: MeCab is the analyzer, while IPADIC and UniDic are dictionaries.
Sudachi is a Japanese morphological analyzer with its own dictionary. One of its distinctive features is the ability to output several segmentation granularities. The example 「選挙管理委員会」 above comes from its documentation. The same input can be analyzed at different levels of detail for different applications.
Kuromoji is implemented in Java and is closely associated with search technology such as Lucene and Solr. It is a familiar option in Java-based search systems.
Juman++ comes from the natural language processing community at 京都大学 (Kyoto University). It combines dictionary candidates with a recurrent neural network language model, using context to select a more plausible analysis. It also produces rich morphological information alongside word boundaries.
There are also tools aimed at Python developers, including Janome, a pure-Python analyzer with a built-in dictionary, and nagisa, a Python library for Japanese morphological analysis. Vaporetto is implemented in Rust and classifies whether a word boundary should appear between adjacent characters. More recent projects such as KWJA bring several Japanese language-analysis tasks together, including tokenization, part-of-speech tagging, and named-entity recognition.
These projects differ in their algorithms, dictionaries, training data, and output conventions. The 2019 article gives more background on several of them. Here, I want to focus on the data that can tell us how well they work.
Raw text is not enough: we need reference annotations
Imagine sending the same news article to several tokenizers and receiving different outputs. That tells us the systems disagree, but it does not tell us which result is more accurate.
To calculate accuracy, we need a corpus whose word boundaries have already been annotated. The original sentence is the question; the annotated segmentation is the reference answer. In natural language processing, this is often called Gold data.
Some corpora contain only raw text. Others also include word boundaries, parts of speech, dictionary forms, and readings. Raw text is useful for observing how a system behaves on real material, but it cannot directly support an accuracy score. For quantitative evaluation, we need a reference annotation against which the output can be compared.
Corpora are also commonly divided into training, development, and test sets. Training data is used to train a model, development data helps with tuning, and test data is held back for the final evaluation. If we repeatedly change a system based on its test results, the system can gradually become tailored to those particular examples. Its score will then say less about how it handles new text.
Several publicly available Japanese resources are especially useful.
UD Japanese-GSD and UD Japanese-PUD
Universal Dependencies (UD) is a cross-linguistic project that maintains treebanks with consistent grammatical annotations, including Japanese.
Japanese-GSD is based on sentences from Google Universal Dependency Treebanks 2.0. Its genres include news and blogs. The current UD v2 treebank contains 8,100 sentences: 7,050 in the training set, 507 in development, and 543 in the test set. The development and test sets together contain 1,050 sentences and 25,321 annotated tokens.
Japanese-PUD is part of a multilingual parallel treebank. It contains 1,000 sentences and 28,788 tokens from news and Wikipedia. There is an interesting detail about its source languages: the first 750 sentences were originally written in English, while the remaining 250 were originally written in German, French, Italian, or Spanish and translated via English. The entire Japanese PUD treebank is designated as a test set. It can therefore help us observe how a tokenizer handles translated Japanese.
Both treebanks provide explicit segmentation annotations and versioned public data, making them useful starting points for reproducible evaluation. Their text distributions are still limited, and their segmentation conventions need attention. GSD’s word units were automatically reprocessed from the earlier bunsetsu-based units toward the Short Unit Word convention; its annotations were also converted into UD conventions. PUD went through a similar conversion process. These are valuable public references, but neither defines the only possible segmentation of all Japanese text.
KWDLC: web documents
The Kyoto University Web Document Leads Corpus, KWDLC, is closer to the material we encounter while browsing the web.
Maintained by 京都大学, it contains the first three sentences from roughly 5,000 web documents, covering news articles, encyclopedic entries, blogs, and commercial pages. The released corpus contains 5,127 documents, 15,381 sentences, and 252,984 morphemes. Its annotations include morphology, named entities, dependency relations, predicate-argument structures, and coreference information.
The morphological and several other annotations were produced by manually revising the output of automatic analyzers such as JUMAN and KNP. This gives us annotated word boundaries and additional linguistic information that can be used in evaluation.
BQNC: informal language from blogs and Q&A sites
One especially interesting resource is the Blog and Q&A site Normalization Corpus (BQNC).
It contains 929 sentences drawn from user-generated blog and Q&A text. The annotations cover ordinary words as well as neologisms and slang, proper names, onomatopoeia, interjections, dialect words, foreign words, emoticons, and non-standard spellings. Examples include 「カワイイ」, 「おいしーい」, and typographical errors.
The corpus contains 12,600 word tokens, including 767 non-standard tokens. Each token is annotated with information such as part of speech, lemma, and pronunciation; non-standard forms can also be linked to their standard forms.
This kind of data matters because well-edited news text is only one part of Japanese. A tokenizer that performs well on news may struggle with expressions found in social media, blogs, and Q&A sites. BQNC was designed to make those problems visible.
The paper and annotation information are publicly available. However, the original sentences come from the blog and Q&A registers in the non-core data of BCCWJ. Reconstructing the complete corpus requires access to the corresponding BCCWJ data.
BCCWJ: a much larger Japanese corpus
The Balanced Corpus of Contemporary Written Japanese (BCCWJ) is maintained by the institute. It contains 104.3 million words across a broad range of genres, including books, magazines, newspapers, business reports, blogs, internet forums, textbooks, and legal documents. Morphological information is provided for its samples.
Its size and genre coverage make it an important resource for understanding written Japanese. There is a historical limitation to keep in mind: the main book samples in BCCWJ1 focus on material from 1986 to 2005, so it cannot fully represent today’s online language. 「少納言」 is available for free searches without an application. 「中納言」 requires registration and an access request, and its online search is also free. The complete offline corpus is available as a paid edition. Commercial use requires separate permission.
BCCWJ is now being expanded as BCCWJ2. The plan is to add data from 2006 to 2025 to the original corpus, bringing the total to roughly 200 million words. On March 24, 2026, the first additional sample became available: approximately 23 million words from books published between 2006 and 2010. Further releases will follow. This expansion will be worth watching for anyone interested in evaluating contemporary Japanese.
Each resource has a different role. GSD and PUD provide public reference benchmarks; KWDLC adds web-document text; BQNC focuses on informal user-generated language; and BCCWJ offers much broader coverage of written Japanese. Their annotation conventions and access conditions differ, so combining all of them into one undifferentiated score would hide important details.
What do Precision, Recall, and F1 actually measure?
Once we have a corpus with reference annotations, we can calculate scores.
A common set of metrics is Precision, Recall, and F1. Their names can sound technical, but a small example makes their purpose much easier to understand.
Suppose the reference segmentation for this sentence is:
今日 / は / 東京 / へ / 行く / 。
That is six tokens. For this illustration, the punctuation mark is counted as a token too. A real evaluation must decide in advance whether punctuation is included.
Now imagine a tokenizer returns:
今日 / は / 東京へ / 行く / 。
It has merged 「東京」 and 「へ」 into one token. Every character from the original sentence is still present, but the segmentation no longer matches the reference.
A token counts as correct only when both its starting and ending positions match the reference exactly. In this example, four tokens match: 今日, は, 行く, and 。.
Precision asks: of all the tokens the program produced, how many were correct?
The program produced five tokens, and four matched the reference:
Precision = 4 ÷ 5 = 80%
Precision tells us how reliable the system’s output is. If it produces many tokens with incorrect boundaries, its Precision falls.
Recall asks: of all the tokens in the reference answer, how many did the program identify correctly?
The reference contains six tokens, and the program correctly identified four:
Recall = 4 ÷ 6 ≈ 66.7%
Recall tells us how much of the expected segmentation the system successfully recovered. In this example, the merge of 「東京」 and 「へ」 means neither reference token is counted as a correct match.
F1 combines Precision and Recall into one score. Its formula gives more influence to the lower of the two scores. A high Precision score cannot hide a much lower Recall score, or vice versa.
For this example, F1 is about 72.7%:
F1 = 2 × 80% × 66.7% ÷ (80% + 66.7%)
In plain language:
- Precision: Of the words the system output, how many did it get right?
- Recall: Of the words in the reference, how many did it find?
- F1: How well did it balance those two goals?
Looking at only one metric can be misleading. A system might output only a few tokens and get most of them right, while missing many others. Another might try to output everything, but produce many incorrect boundaries. F1 reflects both kinds of errors.
Some evaluations also report Boundary F1 separately. It checks each proposed cut position. Token F1 requires both ends of a word to match; Boundary F1 can still give credit for a correct boundary even when the neighboring token is merged. In the example above, the combined token 「東京へ」 is not an exact token match, although its ending boundary is in the right place. Boundary F1 preserves that information and can help locate the type of error.
These metrics measure word boundaries and exact token matches. Part-of-speech tags, dictionary forms, and readings need their own evaluations. Correct segmentation alone does not guarantee that the rest of the morphological analysis is correct.
Scores should be reported separately for different corpora
There is another important point: a single overall score can hide weaknesses.
If a tokenizer has a high F1 on news text but performs much worse on blogs and Q&A material, a combined average may conceal the difference. Results should be reported separately by source and text type, so we can see how the system behaves on edited prose, web documents, and user-generated text.
The segmentation convention also needs to be recorded. Short Unit Words and the units used by JUMAN, for example, can define different boundaries. Comparing scores produced under different conventions does not give us a meaningful ranking.
Dictionary coverage is worth tracking separately as well. What proportion of the reference tokens can be found in the dictionary being used? The unknown-word rate shows how much input must be handled by the unknown-word mechanism. These figures help identify gaps in dictionary coverage, but they do not replace accuracy scores: a word absent from the dictionary can still be segmented correctly.
For domains without an annotated reference corpus, we can begin by collecting real web text and observing how tokenizers handle new words, proper names, mixed numbers and scripts, and informal expressions. When several systems disagree on a sentence, we can select it for annotation and review by people familiar with Japanese. Over time, this creates new evaluation material grounded in real usage.
My preferred order is to establish accuracy first, broaden corpus coverage next, and then optimize speed. A tokenizer has to produce reliable word boundaries before we can judge how many kinds of text it handles or how quickly it runs. F1 measures segmentation quality on the annotated samples; latency, memory use, and dictionary size need separate measurements.
I started by trying to make Japanese dictionaries easier to use. That work led me to tokenization, and then to the question of evaluation. Japanese already has a rich ecosystem of analyzers, dictionaries, and research corpora. What makes building a tokenizer of my own feel more concrete is the possibility of measuring each change against public data and clear evaluation standards. At least then, I can tell whether a modification has genuinely improved the result.
References
- My 2019 article on Japanese tokenizers and dictionaries (Chinese)
- Universal Dependencies: UD Japanese-GSD
- Universal Dependencies: UD Japanese-PUD
- Kyoto University Web Document Leads Corpus (KWDLC)
- User-Generated Text Corpus for Evaluating Japanese Morphological Analysis and Lexical Normalization (BQNC)
- Balanced Corpus of Contemporary Written Japanese (BCCWJ1)
- BCCWJ2
- MeCab
- Sudachi
- Kuromoji
- Juman++
- Janome
- nagisa
- Vaporetto
- KWJA