sudachi.rs

WorksApplicationsApache-2.0活跃维护

用 Rust 重写的日语形态素分析器,也是新一代 SudachiPy 的底层实现,提供分词和词性标注,比原版更快、更省内存。

Sudachi in Rust 🦀 and new generation of SudachiPy

v0.7.0发布于 2026-09-24 01:52 UTC490star64fork同步于 2026-11-07 07:30 UTC

怎么上手

由 README 提炼,执行前请确认
pip install --upgrade 'sudachipy>=0.6.11' 或 git clone https://github.com/WorksApplications/sudachi.rs.git && cd sudachi.rs && cargo build --release && cargo install --path sudachi-cli/ && ./fetch_dictionary.sh
硬件要求按 README 说明

README 未说明硬件要求,未提及显存或 GPU;从构建与运行方式看是纯 CPU 工具。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

Rust 实现的日文形态素分析器,是 SudachiPy 的新一代内核,可做分词与词性标注

用 Rust 重写的日语形态素分析器,也是新一代 SudachiPy 的底层实现,提供分词和词性标注,比原版更快、更省内存。

核心能力

  • 支持 A/B/C 三种切分粒度,可按短单位或命名实体切分
  • 输出表层、词性、标准化的归一化形,加 -a 还给出词典形与读音
  • 用 --wakati 输出空格分隔的表层串,方便下游处理
  • 提供 build/ubuild 子命令构建系统词典与用户词典
  • 同时提供 Rust crate 与 Python 包 sudachipy 两种用法

容易踩的坑

本 crate 不含词典,需另外下载 small/core/full 词典并默认放到 $PWD/system.dic;v0.7 起改用 V1 词典格式,从 v0.6 升级须更新系统词典并基于同一系统词典重建用户词典;v0.7.* 尚不稳定,补丁版本间也可能有破坏性变更,需锁定精确版本;bake_dictionary 特性目前未实现,无法把词典嵌入二进制。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v0.7.0
  1. v0.7.0最新正式版2026-09-24 · 2026-09-24 01:52 UTC

    CAUTION

    The v0.7.* is intended as an intermediate release series before the v1. Please pin the exact version when using this series, as breaking behavioral changes may be introduced even in patch releases.

    Dictionary Binary Format Update: V1

    This release introduced new dictionary format V1. Because of this change, you need to update both of the system dictionary and your user dictionaries. See migration guide for details.

    API Change

    This release introduced many API update including some breaking changes. See migration guide and CHANGELOG.

    Full Changelog: https://github.com/WorksApplications/sudachi.rs/compare/v0.6.11...v0.7.0

  2. v0.6.112026-04-13 · 2026-04-13 05:17 UTC
    查看更新说明

    Highlights

    • Support CPython 3.14 and 3.14t (free-threaded) ( #307 )
    • Add Linux arm64 wheel builds ( #302 )
    • Support Apple embedded platforms (iOS, tvOS, watchOS, visionOS) ( #308 )

    Other

    • Update PyO3 to v0.27 ( #307 )
    • Update dependencies and lockfiles for the 0.6.11 release series ( #303, #311 )
  3. v0.6.102025-01-10 · 2025-01-10 07:26 UTC
    查看更新说明

    Highlights

    • Support py3.13t (wheels are provided only for linux-amd64 and macos-univarsal2) (#284)
    • Broken source distribution in v0.6.9 is fixed (#294)

    Fixed

    • Dictionary.__repr__ for no-user dict case is fixed (#282)

    Other

    • Update build/test workflows (#293, #295)
    • Code refactoring (#283)
    • Update python-support-version badge to python3.9+ (#292)
  4. v0.6.92024-11-20 · 2024-11-20 07:00 UTC
    查看更新说明

    Highlights

    rust

    Added

    • freebsd support (#222 by @KonstantinDjairo, #251)
    • Add option for embedded config and fallback resources (#262 by @Kuuuube)

    Changed

    • fetch_dictionary.sh targets latest dictionary by default (#240)
    • Migrate from structopt to clap (#248 by @tkhshtsh0917)

    python

    Added

    • Allow string literals as SplitMode (#245)
    • Add sudachipy.Config and sudachipy.errors.SudachiError to default import (#260)

    Changed

    • -s (system dictionary path) of sudachi ubuild command is now required (#239)
    • -d option of sudachi cli (which is no-op) now warns (#278)
    • Update the output of sudachi dump subcommand (#277)

    see rust changelog and python changelog for more.

  5. v0.6.82023-12-14 · 2023-12-14 01:45 UTC
    查看更新说明

    Highlights

    • Produce builds for Python 3.12 (#236)
    • Add a simple configuration API
    • Add surface projections (#230)

    Surface Projections

    • For chiTra compatibility SudachiPy can now directly produce different tokens in the surface field.
    • Original surface is accessible via Morheme.raw_surface() method
    • It is possible to customize projection dictionary-wise, via Config object, passing it on a dictionary creation, or for a single pre-tokenizer.

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    sudachi.rs - English README

    Rust

    sudachi.rs is a Rust implementation of Sudachi, a Japanese morphological analyzer.

    日本語 README.

    Python implementation is also available: SudachiPy Documentation.

    IMPORTANT v0.7 introduces a new dictionary format (V1). When upgrading from v0.6, you need to update the system dictionary and rebuild all user dictionaries against the exact system dictionary that will be used at runtime. The URL of the dictionary distribution page is also changed. See the migration guide.

    CAUTION Release v0.7.* is unstable. It may include breaking changes even between patch versions, so please pin the exact version and review release notes carefully before upgrading.

    TL;DR

    Install Python version

    pip install --upgrade 'sudachipy>=0.6.11'
    

    or Rust version

    $ git clone https://github.com/WorksApplications/sudachi.rs.git
    $ cd ./sudachi.rs
    
    $ cargo build --release
    $ cargo install --path sudachi-cli/
    $ ./fetch_dictionary.sh
    
    $ echo "高輪ゲートウェイ駅" | sudachi
    高輪ゲートウェイ駅  名詞,固有名詞,一般,*,*,*    高輪ゲートウェイ駅
    EOS
    

    Example

    Multi-granular Tokenization

    $ echo 選挙管理委員会 | sudachi
    選挙管理委員会  名詞,固有名詞,一般,*,*,*        選挙管理委員会
    EOS
    
    $ echo 選挙管理委員会 | sudachi --mode A
    選挙    名詞,普通名詞,サ変可能,*,*,*    選挙
    管理    名詞,普通名詞,サ変可能,*,*,*    管理
    委員    名詞,普通名詞,一般,*,*,*        委員
    会      名詞,普通名詞,一般,*,*,*        会
    EOS
    

    Normalized Form

    $ echo 打込む かつ丼 附属 vintage | sudachi
    打込む  動詞,一般,*,*,五段-マ行,終止形-一般     打ち込む
            空白,*,*,*,*,*
    かつ丼  名詞,普通名詞,一般,*,*,*        カツ丼
            空白,*,*,*,*,*
    附属    名詞,普通名詞,サ変可能,*,*,*    付属
            空白,*,*,*,*,*
    vintage 名詞,普通名詞,一般,*,*,*        ビンテージ
    EOS
    

    Wakati (space-delimited surface form) Output

    $ cat lemon.txt
    えたいの知れない不吉な塊が私の心を始終圧えつけていた。
    焦躁と言おうか、嫌悪と言おうか――酒を飲んだあとに宿酔があるように、酒を毎日飲んでいると宿酔に相当した時期がやって来る。
    それが来たのだ。これはちょっといけなかった。
    
    $ sudachi --wakati lemon.txt
    えたい の 知れ ない 不吉 な 塊 が 私 の 心 を 始終 圧え つけ て い た 。
    焦躁 と 言おう か 、 嫌悪 と 言おう か ― ― 酒 を 飲ん だ あと に 宿酔 が ある よう に 、 酒 を 毎日 飲ん で いる と 宿酔 に 相当 し た 時期 が やっ て 来る 。
    それ が 来 た の だ 。 これ は ちょっと いけ なかっ た 。
    

    Setup

    You need sudachi.rs, default plugins, and a dictionary. (This crate don't include dictionary.)

    1. Get the source code

    git clone https://github.com/WorksApplications/sudachi.rs.git
    

    2. Download a Sudachi Dictionary

    Sudachi requires a dictionary to operate. There are three types of dictionaries.

    • Small: includes only the vocabulary of UniDic
    • Core: includes basic vocabulary (default)
    • Full: includes miscellaneous proper nouns

    Click here for pre-built dictionaries. Download and unzip a dictionary zip file (choose one of small, core, full of any version), and place the system_*.dic file somewhere. By the default setting file, sudachi.rs assumes that it is placed at $PWD/system.dic.

    For more details, see WorksApplications/SudachiDict.

    Download Script

    Optionally, you can use the fetch_dictionary.sh shell script to download a dictionary and install it to ./system.dic (overrides).

    # fetch latest core dictionary
    ./fetch_dictionary.sh
    
    # fetch dictionary of specified version, type, and format
    ./fetch_dictionary.sh 20241021 small v1
    

    3. Build

    cargo build --release
    
    Build (bake dictionary into binary)

    This was un-implemented and does not work currently, see https://github.com/WorksApplications/sudachi.rs/issues/35

    Specify the bake_dictionary feature to embed a dictionary into the binary. The sudachi executable will contain the dictionary binary. The baked dictionary will be used if no one is specified via cli option or setting file.

    You must specify the path the dictionary file in the SUDACHI_DICT_PATH environment variable when building. SUDACHI_DICT_PATH is relative to the sudachi.rs directory (or absolute).

    Example on Unix-like system:

    # Download dictionary to resources/system.dic
    $ ./fetch_dictionary.sh
    
    # Build with bake_dictionary feature (relative path)
    $ env SUDACHI_DICT_PATH=resources/system.dic cargo build --release --features bake_dictionary
    
    # or
    
    # Build with bake_dictionary feature (absolute path)
    $ env SUDACHI_DICT_PATH=/path/to/my-sudachi.dic cargo build --release --features bake_dictionary
    

    4. Install

    $ cd sudachi.rs/
    $ cargo install --path sudachi-cli/
    
    $ which sudachi
    /Users/<USER>/.cargo/bin/sudachi
    
    $ sudachi -h
    sudachi 0.8.2
    A Japanese tokenizer
    ...
    

    Usage as a command

    $ sudachi -h
    A Japanese tokenizer
    
    Usage: sudachi [OPTIONS] [FILE] [COMMAND]
    
    Commands:
      build
              Builds system dictionary
      ubuild
              Builds user dictionary
      dump
    
      help
              Print this message or the help of the given subcommand(s)
    
    Arguments:
      [FILE]
              Input text file: If not present, read from STDIN
    
    Options:
      -r, --config-file <CONFIG_FILE>
              Path to the setting file in JSON format
      -p, --resource_dir <RESOURCE_DIR>
              Path to the root directory of resources
      -m, --mode <MODE>
              Split unit: "A" (short), "B" (middle), or "C" (Named Entity) [default: C]
      -o, --output <OUTPUT_FILE>
              Output text file: If not present, use stdout
      -a, --all
              Prints all fields
      -w, --wakati
              Outputs only surface form
      -d, --debug
              Debug mode: Print the debug information
      -l, --dict <DICTIONARY_PATH>
              Path to sudachi dictionary. If None, it refer config and then baked dictionary
          --split-sentences <SPLIT_SENTENCES>
              How to split sentences [default: yes]
      -h, --help
              Print help (see more with '--help')
      -V, --version
              Print version
    

    Output

    Columns are tab separated.

    • Surface
    • Part-of-Speech Tags (comma separated)
    • Normalized Form

    When you add the -a (--all) flag, it additionally outputs

    • Dictionary Form
    • Reading Form
    • Dictionary ID
      • 0 for the system dictionary
      • 1 and above for the user dictionaries
      • -1 if a word is Out-of-Vocabulary (not in the dictionary)
    • Synonym group IDs
    • (OOV) if a word is Out-of-Vocabulary (not in the dictionary)
    $ echo "外国人参政権" | sudachi -a
    外国人参政権    名詞,普通名詞,一般,*,*,*        外国人参政権    外国人参政権    ガイコクジンサンセイケン      0       []
    EOS
    
    echo "阿quei" | sudachipy -a
    阿      名詞,普通名詞,一般,*,*,*        阿      阿              -1      []      (OOV)
    quei    名詞,普通名詞,一般,*,*,*        quei    quei            -1      []      (OOV)
    EOS
    

    When you add -w (--wakati) flag, it outputs space-delimited surface instead.

    $ echo "外国人参政権" | sudachi -m A -w
    外国 人 参政 権
    

    API

    See API reference page.

    ToDo

    • Out of Vocabulary handling
    • Easy dictionary file install & management, similar to SudachiPy
    • Registration to crates.io

    References

    Sudachi

    Morphological Analyzers in Rust

    Logo