Skip to content

Commit

Permalink
Merge pull request #37 from snipsco/release/0.55.2
Browse files Browse the repository at this point in the history
Release 0.55.2
  • Loading branch information
Adrien Ball authored Apr 20, 2018
2 parents da54c23 + b08ccc2 commit 6a48f86
Show file tree
Hide file tree
Showing 15 changed files with 50 additions and 58 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# Changelog
All notable changes to this project will be documented in this file.

## [0.55.1] - 2018-04-10
## [0.55.2] - 2018-04-20
### Changed
- Make configurations and pipeline objects public
- Bump snips-nlu-ontology to `0.54.3`

### Fixed
- Bug with prefix and suffix features

## [0.55.1] - 2018-04-10
### Added
- Add support for the `length` feature function in slot filling feature extractrion

Expand All @@ -23,5 +30,6 @@ All notable changes to this project will be documented in this file.
- Rename python package to `snips_nlu_rust`


[0.55.2]: https://github.com/snipsco/snips-nlu-rs/compare/0.55.1...0.55.2
[0.55.1]: https://github.com/snipsco/snips-nlu-rs/compare/0.55.0...0.55.1
[0.55.0]: https://github.com/snipsco/snips-nlu-rs/compare/0.54.0...0.55.0
4 changes: 2 additions & 2 deletions snips-nlu-ffi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
name = "snips-nlu-ffi"
version = "0.55.1"
version = "0.55.2"
authors = [
"Kevin Lefevre <[email protected]>",
"Thibaut Lorrain <[email protected]>"
]

[dependencies]
snips-nlu-lib = { path = "../snips-nlu-lib" }
snips-nlu-ontology-ffi-macros = { git = "https://github.com/snipsco/snips-nlu-ontology", tag = "0.54.2" }
snips-nlu-ontology-ffi-macros = { git = "https://github.com/snipsco/snips-nlu-ontology", tag = "0.54.3" }
failure = "0.1"
lazy_static = "1.0"
libc = "0.2"
Expand Down
2 changes: 1 addition & 1 deletion snips-nlu-ffi/kotlin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ buildscript {

apply plugin: 'kotlin'

version = "0.55.1"
version = "0.55.2"
group = "ai.snips"

repositories {
Expand Down
2 changes: 1 addition & 1 deletion snips-nlu-ffi/python/snips-nlu-python-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ crate-type = ["cdylib"]

[dependencies]
libc = "0.2"
snips-nlu-ffi = { git = "https://github.com/snipsco/snips-nlu-rs", tag = "0.55.1" }
snips-nlu-ffi = { git = "https://github.com/snipsco/snips-nlu-rs", tag = "0.55.2" }
2 changes: 1 addition & 1 deletion snips-nlu-ffi/python/snips_nlu_rust/__version__
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.55.1
0.55.2
2 changes: 1 addition & 1 deletion snips-nlu-ffi/swift/SnipsNlu/Dependencies/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

set -e

VERSION="0.55.1"
VERSION="0.55.2"
SYSTEM=$1

if [ $SYSTEM != ios ] && [ $SYSTEM != macos ]; then
Expand Down
8 changes: 4 additions & 4 deletions snips-nlu-lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "snips-nlu-lib"
version = "0.55.1"
version = "0.55.2"
authors = [
"Thibaut Lorrain <[email protected]>",
"Kevin Lefevre <[email protected]>"
Expand All @@ -11,9 +11,9 @@ description = "Rust implementation of Snips NLU"
[dependencies]
snips-nlu-resources-packed = { path = "../snips-nlu-resources-packed" }
crfsuite = { git = "https://github.com/snipsco/crfsuite-rs", rev = "b18d95c" }
snips-nlu-ontology = { git = "https://github.com/snipsco/snips-nlu-ontology", tag = "0.54.2" }
snips-nlu-ontology-parsers = { git = "https://github.com/snipsco/snips-nlu-ontology", tag = "0.54.2" }
snips-nlu-utils = { git = "https://github.com/snipsco/snips-nlu-utils", tag = "0.6.0" }
snips-nlu-ontology = { git = "https://github.com/snipsco/snips-nlu-ontology", tag = "0.54.3" }
snips-nlu-ontology-parsers = { git = "https://github.com/snipsco/snips-nlu-ontology", tag = "0.54.3" }
snips-nlu-utils = { git = "https://github.com/snipsco/snips-nlu-utils", tag = "0.6.1" }
dinghy-test = "0.3"
failure = "0.1"
base64 = "0.9"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@ impl IntentClassifier for LogRegIntentClassifier {
}
}

impl LogRegIntentClassifier {
pub fn compute_features(&self, input: &str) -> Result<Array1<f32>> {
self.featurizer
.as_ref()
.map(|featurizer| featurizer.transform(input))
.unwrap_or_else(|| Ok(Array::from_iter(vec![])))
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
6 changes: 4 additions & 2 deletions snips-nlu-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ mod utils;

pub const MODEL_VERSION: &str = "0.14.0";

pub use configurations::{FileBasedConfiguration, NluEngineConfiguration,
NluEngineConfigurationConvertible, ZipBasedConfiguration};
pub use configurations::*;
pub use errors::*;
pub use intent_classifier::{IntentClassifier, LogRegIntentClassifier};
pub use intent_parser::{DeterministicIntentParser, IntentParser, ProbabilisticIntentParser};
pub use nlu_engine::SnipsNluEngine;
pub use slot_filler::{CRFSlotFiller, SlotFiller};
pub use nlu_utils::token::{compute_all_ngrams, tokenize_light};
pub use utils::file_path; // This is used by benches
10 changes: 10 additions & 0 deletions snips-nlu-lib/src/slot_filler/crf_slot_filler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,16 @@ impl SlotFiller for CRFSlotFiller {
}
}

impl CRFSlotFiller {
pub fn compute_features(&self, text: &str) -> Vec<Vec<(String, String)>> {
let tokens = tokenize(text, NluUtilsLanguage::from_language(self.language));
if tokens.is_empty() {
return vec![];
};
self.feature_processor.compute_features(&&*tokens)
}
}

// We need to use base64 encoding to ensure ascii encoding because of encoding issues in
// python-crfsuite

Expand Down
4 changes: 2 additions & 2 deletions snips-nlu-lib/src/slot_filler/feature_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ fn prefix_feature_function(
) -> Result<FeatureFunction> {
let n = parse_as_u64(args, "prefix_size")? as usize;
Ok(FeatureFunction::new(
&format!("prefix-{}", n),
&format!("prefix_{}", n),
offsets,
move |t, i| features::prefix(&t[i].value, n),
))
Expand All @@ -185,7 +185,7 @@ fn suffix_feature_function(
) -> Result<FeatureFunction> {
let n = parse_as_u64(args, "suffix_size")? as usize;
Ok(FeatureFunction::new(
&format!("suffix-{}", n),
&format!("suffix_{}", n),
offsets,
move |t, i| features::suffix(&t[i].value, n),
))
Expand Down
4 changes: 2 additions & 2 deletions snips-nlu-lib/src/slot_filler/features.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use itertools::Itertools;

use super::crf_utils::{get_scheme_prefix, TaggingScheme};
use super::features_utils::{get_shape, get_word_chunk, initial_string_from_tokens};
use super::features_utils::{get_word_chunk, initial_string_from_tokens};
use nlu_utils::range::ranges_overlap;
use nlu_utils::string::normalize;
use nlu_utils::string::{get_shape, normalize};
use nlu_utils::token::{compute_all_ngrams, Token};
use resources::gazetteer::Gazetteer;
#[cfg(test)]
Expand Down
37 changes: 0 additions & 37 deletions snips-nlu-lib/src/slot_filler/features_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,6 @@ pub fn get_word_chunk(
}
}

pub fn get_shape(string: &str) -> String {
if string.chars().all(char::is_lowercase) {
"xxx".to_string()
} else if string.chars().all(char::is_uppercase) {
"XXX".to_string()
} else if is_title_case(string) {
"Xxx".to_string()
} else {
"xX".to_string()
}
}

fn is_title_case(string: &str) -> bool {
let mut first = true;
for c in string.chars() {
match (first, c.is_uppercase()) {
(true, true) => first = false,
(false, false) => continue,
_ => return false,
}
}
!first
}

pub fn initial_string_from_tokens(tokens: &[Token]) -> String {
let mut current_index = 0;
let mut chunks: Vec<String> = Vec::with_capacity(2 * tokens.len() - 1);
Expand Down Expand Up @@ -114,19 +90,6 @@ mod tests {
assert_eq!(word_chunk, None);
}

#[test]
fn get_shape_works() {
// Given
let inputs = vec!["héllo", "Héllo", "HÉLLO", "hélLo", "!!", "Éllo", "É"];

// When
let actual_shapes: Vec<String> = inputs.into_iter().map(|i| get_shape(i)).collect();

// Then
let expected_shapes = vec!["xxx", "Xxx", "XXX", "xX", "xX", "Xxx", "XXX"];
assert_eq!(actual_shapes, expected_shapes)
}

#[test]
fn initial_string_from_tokens_works() {
// Given
Expand Down
4 changes: 2 additions & 2 deletions snips-nlu-resources-packed/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
name = "snips-nlu-resources-packed"
version = "0.55.1"
version = "0.55.2"
authors = ["Thibaut Lorrain <[email protected]>"]
build = "build.rs"

[dependencies]
failure = "0.1"
lazy_static = "1.0"
phf = { version = "0.7.21", features = ["unicase"] }
snips-nlu-ontology = { git = "https://github.com/snipsco/snips-nlu-ontology", tag = "0.54.2" }
snips-nlu-ontology = { git = "https://github.com/snipsco/snips-nlu-ontology", tag = "0.54.3" }

[build-dependencies]
snips-nlu-resources = { path = "../snips-nlu-resources"}
Expand Down
4 changes: 2 additions & 2 deletions snips-nlu-resources/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "snips-nlu-resources"
version = "0.55.1"
version = "0.55.2"
authors = ["Thibaut Lorrain <[email protected]>"]

[dependencies]
csv = "0.15"
failure = "0.1"
itertools = { version = "0.7", default-features = false }
lazy_static = "1.0"
snips-nlu-utils = { git = "https://github.com/snipsco/snips-nlu-utils", tag = "0.6.0" }
snips-nlu-utils = { git = "https://github.com/snipsco/snips-nlu-utils", tag = "0.6.1" }

0 comments on commit 6a48f86

Please sign in to comment.