#nlp #chinese #segmenation

jieba-rs

The Jieba Chinese Word Segmentation Implemented in Rust

42 releases

0.7.1 Dec 25, 2024
0.7.0 Apr 16, 2024
0.6.8 Jul 16, 2023
0.6.7 Oct 3, 2022
0.2.3 Jul 6, 2018

#70 in Text processing

Download history 4710/week @ 2024-09-26 4171/week @ 2024-10-03 6075/week @ 2024-10-10 6682/week @ 2024-10-17 7942/week @ 2024-10-24 7981/week @ 2024-10-31 7158/week @ 2024-11-07 7547/week @ 2024-11-14 7825/week @ 2024-11-21 6691/week @ 2024-11-28 7051/week @ 2024-12-05 7197/week @ 2024-12-12 7019/week @ 2024-12-19 6919/week @ 2024-12-26 11706/week @ 2025-01-02 12152/week @ 2025-01-09

38,953 downloads per month
Used in 23 crates (16 directly)

MIT license

4MB
2K SLoC

jieba-rs

GitHub Actions codecov Crates.io docs.rs

🚀 Help me to become a full-time open-source developer by sponsoring me on GitHub

The Jieba Chinese Word Segmentation Implemented in Rust

Installation

Add it to your Cargo.toml:

[dependencies]
jieba-rs = "0.7"

then you are good to go. If you are using Rust 2015 you have to extern crate jieba_rs to your crate root as well.

Example

use jieba_rs::Jieba;

fn main() {
    let jieba = Jieba::new();
    let words = jieba.cut("我们中出了一个叛徒", false);
    assert_eq!(words, vec!["我们", "", "", "", "一个", "叛徒"]);
}

Enabling Additional Features

  • default-dict feature enables embedded dictionary, this features is enabled by default
  • tfidf feature enables TF-IDF keywords extractor
  • textrank feature enables TextRank keywords extractor
[dependencies]
jieba-rs = { version = "0.7", features = ["tfidf", "textrank"] }

Run benchmark

cargo bench --all-features

Benchmark: Compare with cppjieba

jieba-rs bindings

License

This work is released under the MIT license. A copy of the license is provided in the LICENSE file.

Dependencies

~12MB
~122K SLoC