#nlp #chinese #segmenation

jieba-rs

The Jieba Chinese Word Segmentation Implemented in Rust

41 releases

0.7.0 Apr 16, 2024
0.6.8 Jul 16, 2023
0.6.7 Oct 3, 2022
0.6.6 Nov 9, 2021
0.2.3 Jul 6, 2018

#69 in Text processing

Download history 3436/week @ 2024-03-14 5698/week @ 2024-03-21 6485/week @ 2024-03-28 5110/week @ 2024-04-04 5029/week @ 2024-04-11 5193/week @ 2024-04-18 5037/week @ 2024-04-25 4907/week @ 2024-05-02 6272/week @ 2024-05-09 5374/week @ 2024-05-16 5695/week @ 2024-05-23 5528/week @ 2024-05-30 5903/week @ 2024-06-06 4965/week @ 2024-06-13 5913/week @ 2024-06-20 5169/week @ 2024-06-27

22,972 downloads per month
Used in 18 crates (13 directly)

MIT license

4.5MB
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.6"

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.6", 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

~3–5MB
~89K SLoC