#nlp #chinese #segmenation

jieba-rs

The Jieba Chinese Word Segmentation Implemented in Rust

27 releases

✓ Uses Rust 2018 edition

new 0.4.10 Aug 14, 2019
0.4.9 Jul 14, 2019
0.4.7 Jun 29, 2019
0.2.5 Oct 30, 2018
0.2.3 Jul 6, 2018

#45 in Text processing

Download history 17/week @ 2019-05-01 5/week @ 2019-05-08 58/week @ 2019-05-15 64/week @ 2019-05-22 84/week @ 2019-05-29 105/week @ 2019-06-05 119/week @ 2019-06-12 201/week @ 2019-06-19 336/week @ 2019-06-26 182/week @ 2019-07-03 104/week @ 2019-07-10 47/week @ 2019-07-17 12/week @ 2019-07-24 70/week @ 2019-07-31 79/week @ 2019-08-07

482 downloads per month
Used in 3 crates

MIT license

4.5MB
2K SLoC

jieba-rs

Build Status codecov Crates.io docs.rs

The Jieba Chinese Word Segmentation Implemented in Rust

Installation

Add it to your Cargo.toml:

[dependencies]
jieba-rs = "0.4"

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.4", features = ["tfidf", "textrank"] }

Run benchmark

cargo bench --all-features

Benchmark: Compare with cppjieba

License

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

Dependencies

~4MB
~92K SLoC