Skip to content

Commit 206436e

Browse files
authored
Merge pull request #140 from snipsco/release/0.64.3
Release 0.64.3
2 parents b9d4698 + 0a9b0b8 commit 206436e

File tree

21 files changed

+483
-144
lines changed

21 files changed

+483
-144
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [0.64.3] - 2019-04-29
5+
### Fixed
6+
- Make the `WrongModelVersion` error message intelligible [#133](https://github.com/snipsco/snips-nlu-rs/pull/133)
7+
- Fix error handling in Python wrapper [#134](https://github.com/snipsco/snips-nlu-rs/pull/134)
8+
- Return an error when using unknown intents in whitelist or blacklist [#136](https://github.com/snipsco/snips-nlu-rs/pull/136)
9+
- Fix issue with stop words in `DeterministicIntentParser` [#137](https://github.com/snipsco/snips-nlu-rs/pull/137)
10+
- Fix caching issue in `CustomEntityParser` [#138](https://github.com/snipsco/snips-nlu-rs/pull/138)
11+
12+
### Changed
13+
- Re-score ambiguous `DeterministicIntentParser` results based on slots [#139](https://github.com/snipsco/snips-nlu-rs/pull/139)
14+
415
## [0.64.2] - 2019-04-09
516
### Fixed
617
- Fix handling of ambiguous utterances in `DeterministicIntentParser` [#129](https://github.com/snipsco/snips-nlu-rs/pull/129)
@@ -189,6 +200,7 @@ being statically hardcoded, reducing the binary size by 31Mb.
189200
- Improve support for japanese
190201
- Rename python package to `snips_nlu_rust`
191202

203+
[0.64.3]: https://github.com/snipsco/snips-nlu-rs/compare/0.64.2...0.64.3
192204
[0.64.2]: https://github.com/snipsco/snips-nlu-rs/compare/0.64.1...0.64.2
193205
[0.64.1]: https://github.com/snipsco/snips-nlu-rs/compare/0.64.0...0.64.1
194206
[0.64.0]: https://github.com/snipsco/snips-nlu-rs/compare/0.63.1...0.64.0

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "snips-nlu-lib"
3-
version = "0.64.2"
3+
version = "0.64.3"
44
authors = [
55
"Adrien Ball <[email protected]>",
66
"Clement Doumouro <[email protected]>",

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Properly trained, the Snips NLU engine will be able to extract structured data s
3939
{
4040
"intent": {
4141
"intentName": "searchWeatherForecast",
42-
"probability": 0.95
42+
"confidenceScore": 0.95
4343
},
4444
"slots": [
4545
{
@@ -67,7 +67,7 @@ the `Snips NLU python library <https://github.com/snipsco/snips-nlu>`_.
6767
Example and API Usage
6868
---------------------
6969

70-
The `interactive parsing CLI <examples/interactive_parsing_cli>`_ is a good example
70+
The `interactive parsing CLI <examples/interactive_parsing_cli.rs>`_ is a good example
7171
of to how to use ``snips-nlu-rs``.
7272

7373
Here is how you can run the CLI example:

ffi/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "snips-nlu-ffi"
3-
version = "0.64.2"
3+
version = "0.64.3"
44
edition = "2018"
55
authors = [
66
"Adrien Ball <[email protected]>",

ffi/cbindgen.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ language = "c"
22

33
include_guard = "LIBSNIPS_NLU_H_"
44

5-
header = "#define SNIPS_NLU_VERSION \"0.64.2\""
5+
header = "#define SNIPS_NLU_VERSION \"0.64.3\""
66

77
[parse]
88
parse_deps = true

platforms/c/libsnips_nlu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#define SNIPS_NLU_VERSION "0.64.2"
1+
#define SNIPS_NLU_VERSION "0.64.3"
22

33
#ifndef LIBSNIPS_NLU_H_
44
#define LIBSNIPS_NLU_H_

platforms/kotlin/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ buildscript {
1111

1212
apply plugin: 'kotlin'
1313

14-
version = "0.64.2"
14+
version = "0.64.3"
1515
group = "ai.snips"
1616

1717
repositories {

platforms/python/ffi/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "snips-nlu-python-ffi"
3-
version = "0.64.2"
3+
version = "0.64.3"
44
authors = ["Adrien Ball <[email protected]>"]
55
edition = "2018"
66

@@ -11,4 +11,4 @@ crate-type = ["cdylib"]
1111
[dependencies]
1212
libc = "0.2"
1313
ffi-utils = { git = "https://github.com/snipsco/snips-utils-rs", rev = "4292ad9" }
14-
snips-nlu-ffi = { git = "https://github.com/snipsco/snips-nlu-rs", tag = "0.64.2" }
14+
snips-nlu-ffi = { git = "https://github.com/snipsco/snips-nlu-rs", tag = "0.64.3" }
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.64.2
1+
0.64.3

platforms/python/snips_nlu_rust/nlu_engine.py

Lines changed: 47 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55
import json
66
from builtins import object, str
7-
from ctypes import byref, c_char_p, c_void_p, pointer, string_at, c_char, c_int
7+
from ctypes import byref, c_char_p, c_void_p, string_at, c_char, c_int
88
from pathlib import Path
99

10-
from snips_nlu_rust.utils import lib, string_pointer, CStringArray
10+
from snips_nlu_rust.utils import (
11+
lib, string_pointer, CStringArray, check_ffi_error)
1112

1213

1314
class NLUEngine(object):
@@ -32,69 +33,73 @@ class NLUEngine(object):
3233
... engine_dir="/path/to/nlu_engine")
3334
>>> inference_engine.parse("Turn on the lights in the kitchen")
3435
"""
36+
3537
def __init__(self, engine_dir=None, engine_bytes=None):
36-
exit_code = 1
3738
self._engine = None
3839

3940
if engine_dir is None and engine_bytes is None:
4041
raise ValueError("Please specify engine_dir or engine_bytes")
4142

4243
if engine_dir is not None:
4344
engine_dir = Path(engine_dir)
44-
if not engine_dir.is_dir():
45-
raise OSError("NLU engine directory not found: %s"
46-
% str(engine_dir))
47-
self._engine = pointer(c_void_p())
45+
self._engine = c_void_p()
4846
exit_code = lib.ffi_snips_nlu_engine_create_from_dir(
4947
str(engine_dir).encode("utf8"), byref(self._engine))
50-
elif engine_bytes is not None:
51-
self._engine = pointer(c_void_p())
48+
err_msg = "Something went wrong when creating the engine from " \
49+
"directory"
50+
51+
else:
52+
self._engine = c_void_p()
5253
bytearray_type = c_char * len(engine_bytes)
5354
exit_code = lib.ffi_snips_nlu_engine_create_from_zip(
5455
bytearray_type.from_buffer(engine_bytes), len(engine_bytes),
5556
byref(self._engine))
57+
err_msg = "Something went wrong when creating the engine from " \
58+
"bytes"
5659

57-
if exit_code:
58-
raise ImportError('Something wrong happened while creating the '
59-
'intent parser. See stderr.')
60+
check_ffi_error(exit_code, err_msg)
6061

6162
def parse(self, query, intents_whitelist=None, intents_blacklist=None):
6263
"""Extracts intent and slots from an input query
6364
6465
Args:
6566
query (str): input to process
66-
intents_whitelist (list of str, optional): if defined, this will restrict the scope of
67-
intent parsing to the provided intents
68-
intents_blacklist (list of str, optional): if defined, these intents will be excluded
69-
from the scope of intent parsing
67+
intents_whitelist (list of str, optional): if defined, this will
68+
restrict the scope of intent parsing to the provided intents
69+
intents_blacklist (list of str, optional): if defined, these
70+
intents will be excluded from the scope of intent parsing
7071
7172
Returns:
7273
A python dict containing data about intent and slots. See
73-
https://snips-nlu.readthedocs.io/en/latest/tutorial.html#parsing for details about the
74-
format.
74+
https://snips-nlu.readthedocs.io/en/latest/tutorial.html#parsing
75+
for details about the format.
7576
"""
7677
if intents_whitelist is not None:
77-
if not all(isinstance(intent, str) for intent in intents_whitelist):
78-
raise TypeError(
79-
"Expected 'intents_whitelist' to contain objects of type 'str'")
78+
if not all(
79+
isinstance(intent, str) for intent in intents_whitelist):
80+
raise TypeError("Expected 'intents_whitelist' to contain "
81+
"objects of type 'str'")
8082
intents = [intent.encode("utf8") for intent in intents_whitelist]
8183
arr = CStringArray()
8284
arr.size = c_int(len(intents))
8385
arr.data = (c_char_p * len(intents))(*intents)
8486
intents_whitelist = byref(arr)
8587
if intents_blacklist is not None:
86-
if not all(isinstance(intent, str) for intent in intents_blacklist):
87-
raise TypeError(
88-
"Expected 'intents_blacklist' to contain objects of type 'str'")
88+
if not all(
89+
isinstance(intent, str) for intent in intents_blacklist):
90+
raise TypeError("Expected 'intents_blacklist' to contain "
91+
"objects of type 'str'")
8992
intents = [intent.encode("utf8") for intent in intents_blacklist]
9093
arr = CStringArray()
9194
arr.size = c_int(len(intents))
9295
arr.data = (c_char_p * len(intents))(*intents)
9396
intents_blacklist = byref(arr)
9497
with string_pointer(c_char_p()) as ptr:
95-
lib.ffi_snips_nlu_engine_run_parse_into_json(
96-
self._engine, query.encode("utf8"), intents_whitelist, intents_blacklist,
97-
byref(ptr))
98+
exit_code = lib.ffi_snips_nlu_engine_run_parse_into_json(
99+
self._engine, query.encode("utf8"), intents_whitelist,
100+
intents_blacklist, byref(ptr))
101+
msg = "Something went wrong when parsing query '%s'" % query
102+
check_ffi_error(exit_code, msg)
98103
result = string_at(ptr)
99104

100105
return json.loads(result.decode("utf8"))
@@ -108,13 +113,18 @@ def get_slots(self, query, intent):
108113
109114
Returns:
110115
A list of slots. See
111-
https://snips-nlu.readthedocs.io/en/latest/tutorial.html#parsing for details about the
112-
format.
116+
https://snips-nlu.readthedocs.io/en/latest/tutorial.html#parsing
117+
for details about the format.
113118
"""
114119
with string_pointer(c_char_p()) as ptr:
115-
lib.ffi_snips_nlu_engine_run_get_slots_into_json(
116-
self._engine, query.encode("utf8"), intent.encode("utf8"), byref(ptr))
120+
exit_code = lib.ffi_snips_nlu_engine_run_get_slots_into_json(
121+
self._engine, query.encode("utf8"), intent.encode("utf8"),
122+
byref(ptr))
123+
msg = "Something went wrong when extracting slots from query " \
124+
"'%s' with intent '%s'" % (query, intent)
125+
check_ffi_error(exit_code, msg)
117126
result = string_at(ptr)
127+
118128
return json.loads(result.decode("utf8"))
119129

120130
def get_intents(self, query):
@@ -125,12 +135,15 @@ def get_intents(self, query):
125135
126136
Returns:
127137
A list of intents along with their probability. See
128-
https://snips-nlu.readthedocs.io/en/latest/tutorial.html#parsing for details about the
129-
format.
138+
https://snips-nlu.readthedocs.io/en/latest/tutorial.html#parsing
139+
for details about the format.
130140
"""
131141
with string_pointer(c_char_p()) as ptr:
132-
lib.ffi_snips_nlu_engine_run_get_intents_into_json(
142+
exit_code = lib.ffi_snips_nlu_engine_run_get_intents_into_json(
133143
self._engine, query.encode("utf8"), byref(ptr))
144+
msg = "Something went wrong when extracting intents from query " \
145+
"'%s'" % query
146+
check_ffi_error(exit_code, msg)
134147
result = string_at(ptr)
135148
return json.loads(result.decode("utf8"))
136149

0 commit comments

Comments
 (0)