43 releases

0.7.2 Jan 21, 2025
0.7.1 Dec 25, 2024
0.7.0 Apr 16, 2024
0.6.8 Jul 16, 2023
0.2.3 Jul 6, 2018

#72 in Text processing

Download history 7304/week @ 2024-12-20 7523/week @ 2024-12-27 11697/week @ 2025-01-03 12988/week @ 2025-01-10 9775/week @ 2025-01-17 5848/week @ 2025-01-24 6275/week @ 2025-01-31 12392/week @ 2025-02-07 8839/week @ 2025-02-14 8367/week @ 2025-02-21 9860/week @ 2025-02-28 9963/week @ 2025-03-07 9692/week @ 2025-03-14 9546/week @ 2025-03-21 10986/week @ 2025-03-28 8882/week @ 2025-04-04

40,609 downloads per month
Used in 27 crates (18 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
~121K SLoC