@nikkei/napi-sudachi
v0.12.0
Published
Sudachi.rs for Node.js with napi-rs
Readme
napi-sudachi
napi-rs implementation of Sudachi.rs
TL;DR
Install package
npm install @nikkei/napi-sudachiUsage
const sudachi = require('@nikkei/napi-sudachi')
const tokenizer = new sudachi.Tokenizer()
const mode = sudachi.SplitMode.c()
const testText = 'すもももももももものうち'
const morphemes = tokenizer.tokenize(testText, mode)
morphemes[0] >>
{
surface: 'すもも',
partOfSpeech: ['名詞', '普通名詞', '一般', '*', '*', '*'],
normalizedForm: '李',
dictionaryForm: 'すもも',
readingForm: 'スモモ',
dictionaryId: 0,
}Setup
Setup must be done the same way as for Sudachi.rs.
- Download the Sudachi dictionary
- Non-dictionary configuration is already included in resources, which is a fork of
sudachi.rs/resources
Download a Sudachi Dictionary
You can use yarn setup-dictionary / npm run setup-dictionary to download a dictionary in resources/ directory
Like sudachi.rs/fetch_dictionary.sh, this downloads the latest SudachiDict.
You can also pass version and type as arguments.
yarn setup-dictionary 20241021 small
# or
npm run setup-dictionary -- 20241021 smallConfig
You can set environment variable for config in sudachi
SUDACHI_CONFIG_FILE:config.jsonpathSUDACHI_RESOURCE_DIR:resources/pathSUDACHI_DICT_PATH: dictionary pathSUDACHI_USER_DICT: user dictionary path (optional, if not set, user_dict will not be configured)
For Developers
based on napi-rs/package-template
Requirements
- the latest
Rust Node.jsyarn
Build
After yarn build command, you can see napi-sudachi.[darwin|win32|linux].node file in project root.
This is the native addon built from lib.rs.
Test in local
yarn
yarn build
yarn testCI
With GitHub Actions, each commit and pull request will be built and tested automatically. For the list of supported Node.js versions and operating systems, please refer to .github/workflows/CI.yml.
Release package
Releases are triggered by pushing a semver Git tag.
- On a release branch, bump the version (updates platform packages via napi-rs hooks):
npm version [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease [--preid=<prerelease-id>] | from-git]Open a PR with the version bump and merge it into
main.After the merge, tag the merge commit on
mainand push the tag (must matchpackage.jsonversion, with avprefix):
git checkout main && git pull
git tag vX.Y.Z
git push origin vX.Y.ZGitHub actions will do the rest job for you.
WARN: Don't run
npm publishmanually.
Copyright 2026 Nikkei Inc.
