#search #tokenizer #Chinese #tantivy

cang-jie

A Chinese tokenizer for tantivy

3 releases (breaking)

✓ Uses Rust 2018 edition

0.3.0 Mar 21, 2019
0.2.0 Feb 11, 2019
0.1.0 Sep 18, 2018

#243 in Algorithms

25 downloads per month

MIT license

6KB
100 lines

cang-jie(仓颉)

Crates.io Build Status latest document dependency status

A Chinese tokenizer for tantivy, based on jieba-rs.

As of now, only support UTF-8.

Example

    let mut schema_builder = SchemaBuilder::default();
    let text_indexing = TextFieldIndexing::default()
        .set_tokenizer(CANG_JIE) // Set custom tokenizer
        .set_index_option(IndexRecordOption::WithFreqsAndPositions);
    let text_options = TextOptions::default()
        .set_indexing_options(text_indexing)
        .set_stored();
    // ... Some code   
     let index = Index::create(RAMDirectory::create(), schema.clone())?;
     let tokenizer = CangJieTokenizer {
                        worker: Arc::new(Jieba::empty()), // empty dictionary
                        option: TokenizerOption::Unicode,
                     };
     index.tokenizers().register(CANG_JIE, tokenizer); 
    // ... Some code

Full example

Dependencies

~19MB
~214K SLoC