/snips-nlu-parsers

Rust crate for entity parsing

Primary LanguageRustOtherNOASSERTION

Snips NLU Parsers

https://travis-ci.org/snipsco/snips-nlu-parsers.svg?branch=master https://ci.appveyor.com/api/projects/status/github/snipsco/snips-nlu-parsers?branch=master&svg=true

This Rust crate provides APIs to extract entities in the context of a Natural Language Understanding (NLU) task.

A Python wrapper is also available.

Installation

Add this to your Cargo.toml:

[dependencies]
snips-nlu-parsers = { git = "https://github.com/snipsco/snips-nlu-parsers", tag = "0.1.0" }

Usage

use snips_nlu_parsers::{BuiltinEntityKind, BuiltinEntityParserLoader, Language};

fn parse_entities() {
    let parser = BuiltinEntityParserLoader::new(Language::EN).load().unwrap();
    let entities: Vec<(_, _)> = parser
        .extract_entities("Book me restaurant for two people tomorrow", None)
        .unwrap()
        .into_iter()
        .map(|e| (e.entity_kind, e.range))
        .collect();
    assert_eq!(
        vec![
            (BuiltinEntityKind::Number, 23..26),
            (BuiltinEntityKind::Time, 34..42)
        ],
        entities
    );
}

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.