libsimple 0.1.0

Rust bindings to simple, a SQLite3 fts5 tokenizer which supports Chinese and PinYin.
docs.rs failed to build libsimple-0.1.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: libsimple-0.6.1

libsimple

Crate GitHub last commit GitHub issues GitHub pull requests GitHub

Description

Rust bindings to simple, a SQLite3 fts5 tokenizer which supports Chinese and PinYin.

Usage

Add this to your Cargo.toml:

[dependencies]

libsimple = "~0.1"

Example

use anyhow::Result;
use tempfile::tempdir;

fn main() -> Result<()> {
    let dir = tempdir()?;
    libsimple::initialize(&dir)?;
    let conn = rusqlite::Connection::open_in_memory()?;
    libsimple::load(&conn)?;
    conn.execute_batch("
        CREATE TABLE singer (id INTEGER, name TEXT);
        CREATE VIRTUAL TABLE d USING fts5(id, name, tokenize = 'simple');
        CREATE TRIGGER insert_trigger AFTER INSERT ON singer BEGIN
            INSERT INTO d(id, name) VALUES (new.id, new.name);
        END;
        INSERT INTO singer (id, name) VALUES (1, '周杰伦');
    ")?;
    assert_eq!(conn.query_row("SELECT id FROM d WHERE name MATCH simple_query('zhoujiel')",
                              [], |row| row.get::<_, i64>(0))?, 1);
    Ok(())
}

Note

To build this crate, please make sure you have installed make and cmake.

This crate will clone the cppjieba from GitHub when you build, so make sure you have the network access.

License

Licensed under MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)