Getting Started
Suzume is a lightweight Japanese tokenizer for JavaScript/WASM, Python, Go, native C/C++, and the command line. It splits Japanese text into tokens and gives each token a part of speech and a base form. Type a sentence below to see the result, then follow the steps for your runtime.
Try it in the browser
Nothing is sent to a server. The Suzume WASM bundled with this page tokenizes, lemmatizes, and extracts tags locally.
Choose a Binding
Each step on this page has one tab per binding:
| Tab | Runtime | Package | Reference |
|---|---|---|---|
| JavaScript | Browser, Node.js, Deno, Bun | @libraz/suzume on npm | API Reference |
| Python | CPython 3.10+ on Linux x86_64 or macOS arm64 | suzume on PyPI | Python guide |
| Go | Go 1.26+ with cgo | github.com/libraz/go-suzume | Go bindings |
| C++ | Native C or C++ program | Built from source | C / C++ library |
| CLI | Shell | suzume command from the PyPI wheel | Python CLI |
Install
npm install @libraz/suzumepip install suzumegit clone https://github.com/libraz/go-suzume.git
cd go-suzume && make lib
# From your own module:
go mod edit -replace github.com/libraz/go-suzume=/path/to/go-suzume
go get github.com/libraz/go-suzumegit clone https://github.com/libraz/suzume.git
cd suzume
make install # into /usr/local; override with PREFIX=/opt/suzumepip install suzume # the wheel also installs the suzume commandInstallation covers other package managers, the CDN build, platform requirements, and the native suzume-cli developer tool.
Analyze Text
import { Suzume } from '@libraz/suzume'
const suzume = await Suzume.create()
for (const m of suzume.analyze('東京で美味しいラーメンを食べた')) {
console.log(`${m.surface}\t${m.pos}\t${m.baseForm}`)
}
suzume.destroy()from suzume import Suzume
with Suzume() as suzume:
for m in suzume.analyze("東京で美味しいラーメンを食べた"):
print(f"{m.surface}\t{m.pos}\t{m.base_form}")package main
import (
"fmt"
"log"
"github.com/libraz/go-suzume"
)
func main() {
analyzer, err := suzume.New()
if err != nil {
log.Fatal(err)
}
defer analyzer.Close()
morphemes, err := analyzer.Analyze("東京で美味しいラーメンを食べた")
if err != nil {
log.Fatal(err)
}
for _, m := range morphemes {
fmt.Printf("%s\t%s\t%s\n", m.Surface, m.POS, m.BaseForm)
}
}#include <iostream>
#include "suzume/suzume.hpp"
int main() {
auto tokenizer = suzume::Tokenizer::create();
if (!tokenizer) return 1;
const auto morphemes = tokenizer->analyze("東京で美味しいラーメンを食べた");
if (!morphemes) return 1;
for (const auto& m : *morphemes) {
std::cout << m.surface << '\t' << m.pos << '\t' << m.base_form << '\n';
}
}suzume "東京で美味しいラーメンを食べた"Each printed line is one token, with its surface, part of speech, and base form separated by tabs:
The CLI prints the same three columns followed by the start and end offsets. 食べ is the continuative form, the form a verb takes before た.
A token carries more than these three fields: conjugation type and form, offsets, and flags such as isUserDict and isUnknown. The full field list is in the Morpheme interface. Offsets count Unicode code points in the normalized text; see Offsets before slicing the input with them.
Construction options select the analysis mode and whether noun compounds merge; see Modes, Offsets, and Normalization. Every option and its default is listed under Suzume.create(options?).
Common Tasks
These snippets reuse the instance from Analyze Text, so run them before it is destroyed or closed.
Extract Search Keywords
generateTags() drops particles, auxiliaries, formal nouns, and low-information words, and returns the base form of each remaining token. excludeBasic also drops words whose base form is all hiragana.
const tags = suzume.generateTags('東京スカイツリーで夜景を撮影しました', {
excludeBasic: true,
maxTags: 5,
})
for (const t of tags) {
console.log(`${t.tag}\t${t.pos}`)
}tags = suzume.generate_tags(
"東京スカイツリーで夜景を撮影しました",
exclude_basic=True,
max_tags=5,
)
for t in tags:
print(f"{t.tag}\t{t.pos}")opts := suzume.DefaultTagOptions()
opts.ExcludeBasic = true
opts.MaxTags = 5
tags, err := analyzer.GenerateTagsWithOptions("東京スカイツリーで夜景を撮影しました", opts)
if err != nil {
log.Fatal(err)
}
for _, t := range tags {
fmt.Printf("%s\t%s\n", t.Tag, t.POS)
}suzume::TagOptions opts;
opts.exclude_basic = true;
opts.max_tags = 5;
const auto tags = tokenizer->generateTags("東京スカイツリーで夜景を撮影しました", opts);
if (!tags) return 1;
for (const auto& t : *tags) {
std::cout << t.tag << '\t' << t.pos << '\n';
}suzume -f tags --tag-exclude-basic --tag-max-tags 5 "東京スカイツリーで夜景を撮影しました"東京 NOUN
スカイツリー NOUN
夜景 NOUN
撮影 NOUNAll tabs print this output. See generateTags(text, options?) for the remaining filters.
Normalize Conjugated Words
Every token in a conjugated chain reports its own base form, so mapping surfaces to base forms undoes the inflection.
for (const m of suzume.analyze('食べさせられなかった')) {
if (m.surface !== m.baseForm) {
console.log(`${m.surface} -> ${m.baseForm}`)
}
}for m in suzume.analyze("食べさせられなかった"):
if m.surface != m.base_form:
print(f"{m.surface} -> {m.base_form}")conjugated, err := analyzer.Analyze("食べさせられなかった")
if err != nil {
log.Fatal(err)
}
for _, m := range conjugated {
if m.Surface != m.BaseForm {
fmt.Printf("%s -> %s\n", m.Surface, m.BaseForm)
}
}const auto conjugated = tokenizer->analyze("食べさせられなかった");
if (!conjugated) return 1;
for (const auto& m : *conjugated) {
if (m.surface != m.base_form) {
std::cout << m.surface << " -> " << m.base_form << '\n';
}
}# Prints every token; the third column is the base form.
suzume "食べさせられなかった"食べ -> 食べる
させ -> させる
られ -> られる
なかっ -> ないThe final た is already its own base form, so the filter skips it.
Next Steps
| Page | Read it for |
|---|---|
| Installation | Package managers, CDN, platform requirements, suzume-cli |
| User Dictionary | Adding domain words |
| Modes, Offsets, and Normalization | Analysis modes, compound merging, offsets |
| Glossary | Terms used in the output and these docs |
| How It Works | The analysis pipeline |
| Native CLI | Dictionary compilation and test workflows |