#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

#82 in Text processing

Download history 5793/week @ 2024-07-23 5284/week @ 2024-07-30 5341/week @ 2024-08-06 5872/week @ 2024-08-13 5619/week @ 2024-08-20 4909/week @ 2024-08-27 6780/week @ 2024-09-03 5320/week @ 2024-09-10 5223/week @ 2024-09-17 6042/week @ 2024-09-24 3023/week @ 2024-10-01 6085/week @ 2024-10-08 6029/week @ 2024-10-15 7702/week @ 2024-10-22 7885/week @ 2024-10-29 7674/week @ 2024-11-05

30,333 downloads per month
Used in 20 crates (14 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
~88K SLoC