Skip to content

Commit 1f1d0ef

Browse files
author
Kevin Lefèvre
authored
Merge pull request #40 from snipsco/release/0.56.0
Release 0.56.0
2 parents 6a48f86 + 09e8ce7 commit 1f1d0ef

File tree

23 files changed

+290
-340
lines changed

23 files changed

+290
-340
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ matrix:
1515
- TOXENV=py36
1616
- PYTHON_TESTS=true
1717
- os: osx
18-
osx_image: xcode9.2
18+
osx_image: xcode9.3
1919
language: generic
2020
env:
2121
- MACOS_SWIFT_TESTS=true
2222
- os: osx
23-
osx_image: xcode9.2
23+
osx_image: xcode9.3
2424
language: generic
2525
env:
2626
- IOS_SWIFT_TESTS=true
@@ -61,7 +61,7 @@ before_install: . ./.travis/before_install.sh
6161

6262
install: ./.travis/install.sh
6363

64-
script: travis_wait 30 bash ./.travis/test.sh
64+
script: travis_wait 40 bash ./.travis/test.sh
6565

6666
git:
6767
depth: 10

.travis/test.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ if [ "${MACOS_SWIFT_TESTS}" == "true" ]; then
4040
-workspace SnipsNlu.xcworkspace \
4141
-scheme SnipsNlu-macOS \
4242
TARGET_BUILD_TYPE=debug \
43+
SNIPS_USE_LOCAL=1 \
4344
clean \
4445
test \
4546
| xcpretty
@@ -58,6 +59,7 @@ if [ "${IOS_SWIFT_TESTS}" == "true" ]; then
5859
-scheme SnipsNlu-iOS \
5960
-destination 'platform=iOS Simulator,name=iPhone 8,OS=latest' \
6061
TARGET_BUILD_TYPE=debug \
62+
SNIPS_USE_LOCAL=1 \
6163
clean \
6264
test \
6365
| xcpretty

CHANGELOG.md

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

4+
## [0.56.0] - 2018-05-03
5+
### Changed
6+
- Change ffi signatures
7+
- Update swift project to Xcode 9.3
8+
- Bump snips-nlu-ontology to `0.55.0`
9+
410
## [0.55.2] - 2018-04-20
511
### Changed
612
- Make configurations and pipeline objects public
@@ -30,6 +36,7 @@ All notable changes to this project will be documented in this file.
3036
- Rename python package to `snips_nlu_rust`
3137

3238

39+
[0.56.0]: https://github.com/snipsco/snips-nlu-rs/compare/0.55.2...0.56.0
3340
[0.55.2]: https://github.com/snipsco/snips-nlu-rs/compare/0.55.1...0.55.2
3441
[0.55.1]: https://github.com/snipsco/snips-nlu-rs/compare/0.55.0...0.55.1
35-
[0.55.0]: https://github.com/snipsco/snips-nlu-rs/compare/0.54.0...0.55.0
42+
[0.55.0]: https://github.com/snipsco/snips-nlu-rs/compare/0.54.0...0.55.0

snips-nlu-ffi/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
[package]
22
name = "snips-nlu-ffi"
3-
version = "0.55.2"
3+
version = "0.56.0"
44
authors = [
55
"Kevin Lefevre <[email protected]>",
66
"Thibaut Lorrain <[email protected]>"
77
]
88

99
[dependencies]
10+
ffi-utils = { git = "https://github.com/snipsco/snips-utils-rs", rev = "b1f4af3" }
1011
snips-nlu-lib = { path = "../snips-nlu-lib" }
11-
snips-nlu-ontology-ffi-macros = { git = "https://github.com/snipsco/snips-nlu-ontology", tag = "0.54.3" }
12+
snips-nlu-ontology-ffi-macros = { git = "https://github.com/snipsco/snips-nlu-ontology", tag = "0.55.0" }
1213
failure = "0.1"
1314
lazy_static = "1.0"
1415
libc = "0.2"

snips-nlu-ffi/c/libsnips_nlu.h

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,33 @@
55
extern "C" {
66
#endif
77

8-
typedef enum CPrecision {
9-
APPROXIMATE = 0,
10-
EXACT = 1,
11-
} CPrecision;
12-
13-
typedef enum CGrain {
14-
YEAR = 0,
15-
QUARTER = 1,
16-
MONTH = 2,
17-
WEEK = 3,
18-
DAY = 4,
19-
HOUR = 5,
20-
MINUTE = 6,
21-
SECOND = 7,
22-
} CGrain;
23-
24-
typedef enum CSlotValueType {
25-
CUSTOM = 1,
26-
NUMBER = 2,
27-
ORDINAL = 3,
28-
INSTANTTIME = 4,
29-
TIMEINTERVAL = 5,
30-
AMOUNTOFMONEY = 6,
31-
TEMPERATURE = 7,
32-
DURATION = 8,
33-
PERCENTAGE = 9,
34-
} CSlotValueType;
8+
typedef enum SNIPS_PRECISION {
9+
SNIPS_PRECISION_APPROXIMATE = 0,
10+
SNIPS_PRECISION_EXACT = 1,
11+
} SNIPS_PRECISION;
12+
13+
typedef enum SNIPS_GRAIN {
14+
SNIPS_GRAIN_YEAR = 0,
15+
SNIPS_GRAIN_QUARTER = 1,
16+
SNIPS_GRAIN_MONTH = 2,
17+
SNIPS_GRAIN_WEEK = 3,
18+
SNIPS_GRAIN_DAY = 4,
19+
SNIPS_GRAIN_HOUR = 5,
20+
SNIPS_GRAIN_MINUTE = 6,
21+
SNIPS_GRAIN_SECOND = 7,
22+
} SNIPS_GRAIN;
23+
24+
typedef enum SNIPS_SLOT_VALUE_TYPE {
25+
SNIPS_SLOT_VALUE_TYPE_CUSTOM = 1,
26+
SNIPS_SLOT_VALUE_TYPE_NUMBER = 2,
27+
SNIPS_SLOT_VALUE_TYPE_ORDINAL = 3,
28+
SNIPS_SLOT_VALUE_TYPE_INSTANTTIME = 4,
29+
SNIPS_SLOT_VALUE_TYPE_TIMEINTERVAL = 5,
30+
SNIPS_SLOT_VALUE_TYPE_AMOUNTOFMONEY = 6,
31+
SNIPS_SLOT_VALUE_TYPE_TEMPERATURE = 7,
32+
SNIPS_SLOT_VALUE_TYPE_DURATION = 8,
33+
SNIPS_SLOT_VALUE_TYPE_PERCENTAGE = 9,
34+
} SNIPS_SLOT_VALUE_TYPE;
3535

3636
typedef double CNumberValue;
3737

@@ -41,8 +41,8 @@ typedef long COrdinalValue;
4141

4242
typedef struct CInstantTimeValue {
4343
char *const value;
44-
CGrain grain;
45-
CPrecision precision;
44+
SNIPS_GRAIN grain;
45+
SNIPS_PRECISION precision;
4646
} CInstantTimeValue;
4747

4848
typedef struct CTimeIntervalValue {
@@ -52,7 +52,7 @@ typedef struct CTimeIntervalValue {
5252

5353
typedef struct CAmountOfMoneyValue {
5454
float value;
55-
CPrecision precision;
55+
SNIPS_PRECISION precision;
5656
char *const unit;
5757
} CAmountOfMoneyValue;
5858

@@ -70,11 +70,11 @@ typedef struct CDurationValue {
7070
long hours;
7171
long minutes;
7272
long seconds;
73-
CPrecision precision;
73+
SNIPS_PRECISION precision;
7474
} CDurationValue;
7575

7676
typedef struct CSlotValue {
77-
CSlotValueType value_type;
77+
SNIPS_SLOT_VALUE_TYPE value_type;
7878
/**
7979
* Points to either a char *const, a CNumberValue, a COrdinalValue,
8080
* a CInstantTimeValue, a CTimeIntervalValue, a CAmountOfMoneyValue,
@@ -108,32 +108,32 @@ typedef struct CIntentParserResult{
108108
CSlotList *const slots;
109109
} CIntentParserResult;
110110

111-
typedef struct Opaque Opaque;
111+
typedef struct CSnipsNluEngine CSnipsNluEngine;
112112

113-
typedef enum NLURESULT {
114-
KO = 0,
115-
OK = 1,
116-
} NLURESULT;
113+
typedef enum SNIPS_RESULT {
114+
SNIPS_RESULT_OK = 0,
115+
SNIPS_RESULT_KO = 1,
116+
} SNIPS_RESULT;
117117

118-
NLURESULT nlu_engine_create_from_file(char const* file_path, Opaque** client);
118+
SNIPS_RESULT snips_nlu_engine_create_from_file(char const* file_path, CSnipsNluEngine** client);
119119

120-
NLURESULT nlu_engine_create_from_dir(char const* root_dir, Opaque** client);
120+
SNIPS_RESULT snips_nlu_engine_create_from_dir(char const* root_dir, CSnipsNluEngine** client);
121121

122-
NLURESULT nlu_engine_create_from_zip(unsigned char const* zip, unsigned int zip_size, Opaque** client);
122+
SNIPS_RESULT snips_nlu_engine_create_from_zip(unsigned char const* zip, unsigned int zip_size, CSnipsNluEngine** client);
123123

124-
NLURESULT nlu_engine_run_parse(Opaque const* client, char const* input, CIntentParserResult** result);
124+
SNIPS_RESULT snips_nlu_engine_run_parse(CSnipsNluEngine const* client, char const* input, CIntentParserResult** result);
125125

126-
NLURESULT nlu_engine_run_parse_into_json(Opaque const* client, char const* input, char** result_json);
126+
SNIPS_RESULT snips_nlu_engine_run_parse_into_json(CSnipsNluEngine const* client, char const* input, char** result_json);
127127

128-
NLURESULT nlu_engine_destroy_string(char* string);
128+
SNIPS_RESULT snips_nlu_engine_destroy_string(char* string);
129129

130-
NLURESULT nlu_engine_destroy_client(Opaque* client);
130+
SNIPS_RESULT snips_nlu_engine_destroy_client(CSnipsNluEngine* client);
131131

132-
NLURESULT nlu_engine_destroy_result(CIntentParserResult* result);
132+
SNIPS_RESULT snips_nlu_engine_destroy_result(CIntentParserResult* result);
133133

134-
NLURESULT nlu_engine_get_last_error(char **error);
134+
SNIPS_RESULT snips_nlu_engine_get_last_error(char **error);
135135

136-
NLURESULT nlu_engine_get_model_version(char **version);
136+
SNIPS_RESULT snips_nlu_engine_get_model_version(char **version);
137137

138138
#ifdef __cplusplus
139139
}

snips-nlu-ffi/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.55.2"
14+
version = "0.56.0"
1515
group = "ai.snips"
1616

1717
repositories {

snips-nlu-ffi/kotlin/src/main/kotlin/ai/snips/nlu/NluEngine.kt

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,66 +16,66 @@ class NluEngine private constructor(clientBuilder: () -> Pointer) : Closeable {
1616

1717
companion object {
1818
private fun parseError(returnCode: Int) {
19-
if (returnCode != 1) {
19+
if (returnCode != 0) {
2020
PointerByReference().apply {
21-
LIB.nlu_engine_get_last_error(this)
21+
LIB.snips_nlu_engine_get_last_error(this)
2222
throw RuntimeException(value.getString(0).apply {
23-
LIB.nlu_engine_destroy_string(value)
23+
LIB.snips_nlu_engine_destroy_string(value)
2424
})
2525
}
2626
}
2727
}
2828

2929
@JvmStatic
3030
fun modelVersion(): String = PointerByReference().run {
31-
parseError(LIB.nlu_engine_get_model_version(this))
32-
value.getString(0).apply { LIB.nlu_engine_destroy_string(value) }
31+
parseError(LIB.snips_nlu_engine_get_model_version(this))
32+
value.getString(0).apply { LIB.snips_nlu_engine_destroy_string(value) }
3333
}
3434
}
3535

3636
constructor(assistant: File) :
3737
this({
3838
PointerByReference().apply {
3939
if (assistant.isDirectory) {
40-
parseError(LIB.nlu_engine_create_from_dir(assistant.absolutePath.toPointer(), this))
40+
parseError(LIB.snips_nlu_engine_create_from_dir(assistant.absolutePath.toPointer(), this))
4141
} else {
42-
parseError(LIB.nlu_engine_create_from_file(assistant.absolutePath.toPointer(), this))
42+
parseError(LIB.snips_nlu_engine_create_from_file(assistant.absolutePath.toPointer(), this))
4343
}
4444
}.value
4545
})
4646

4747
constructor(data: ByteArray) :
4848
this({
4949
PointerByReference().apply {
50-
parseError(LIB.nlu_engine_create_from_zip(data, data.size, this))
50+
parseError(LIB.snips_nlu_engine_create_from_zip(data, data.size, this))
5151
}.value
5252
})
5353

5454

5555
val client: Pointer = clientBuilder()
5656

5757
override fun close() {
58-
LIB.nlu_engine_destroy_client(client)
58+
LIB.snips_nlu_engine_destroy_client(client)
5959
}
6060

6161
fun parse(input: String): IntentParserResult =
6262
CIntentParserResult(PointerByReference().apply {
63-
parseError(LIB.nlu_engine_run_parse(client, input.toPointer(), this))
63+
parseError(LIB.snips_nlu_engine_run_parse(client, input.toPointer(), this))
6464
}.value).let {
6565
it.toIntentParserResult().apply {
6666
// we don't want jna to try and sync this struct after the call as we're destroying it
6767
// /!\ removing that will make the app crash semi randomly...
6868
it.autoRead = false
69-
LIB.nlu_engine_destroy_result(it)
69+
LIB.snips_nlu_engine_destroy_result(it)
7070
}
7171
}
7272

7373
fun parseIntoJson(input: String): String =
7474
PointerByReference().apply {
75-
parseError(LIB.nlu_engine_run_parse_into_json(client, input.toPointer(), this))
75+
parseError(LIB.snips_nlu_engine_run_parse_into_json(client, input.toPointer(), this))
7676
}.value.let {
7777
it.readString().apply {
78-
LIB.nlu_engine_destroy_string(it)
78+
LIB.snips_nlu_engine_destroy_string(it)
7979
}
8080
}
8181

@@ -84,15 +84,15 @@ class NluEngine private constructor(clientBuilder: () -> Pointer) : Closeable {
8484
val INSTANCE: SnipsNluClientLibrary = Native.loadLibrary("snips_nlu_ffi", SnipsNluClientLibrary::class.java)
8585
}
8686

87-
fun nlu_engine_get_model_version(version: PointerByReference): Int
88-
fun nlu_engine_create_from_file(file_path: Pointer, pointer: PointerByReference): Int
89-
fun nlu_engine_create_from_dir(root_dir: Pointer, pointer: PointerByReference): Int
90-
fun nlu_engine_create_from_zip(data: ByteArray, data_size: Int, pointer: PointerByReference): Int
91-
fun nlu_engine_run_parse(client: Pointer, input: Pointer, result: PointerByReference): Int
92-
fun nlu_engine_run_parse_into_json(client: Pointer, input: Pointer, result: PointerByReference): Int
93-
fun nlu_engine_get_last_error(error: PointerByReference): Int
94-
fun nlu_engine_destroy_client(client: Pointer): Int
95-
fun nlu_engine_destroy_result(result: CIntentParserResult): Int
96-
fun nlu_engine_destroy_string(string: Pointer): Int
87+
fun snips_nlu_engine_get_model_version(version: PointerByReference): Int
88+
fun snips_nlu_engine_create_from_file(file_path: Pointer, pointer: PointerByReference): Int
89+
fun snips_nlu_engine_create_from_dir(root_dir: Pointer, pointer: PointerByReference): Int
90+
fun snips_nlu_engine_create_from_zip(data: ByteArray, data_size: Int, pointer: PointerByReference): Int
91+
fun snips_nlu_engine_run_parse(client: Pointer, input: Pointer, result: PointerByReference): Int
92+
fun snips_nlu_engine_run_parse_into_json(client: Pointer, input: Pointer, result: PointerByReference): Int
93+
fun snips_nlu_engine_get_last_error(error: PointerByReference): Int
94+
fun snips_nlu_engine_destroy_client(client: Pointer): Int
95+
fun snips_nlu_engine_destroy_result(result: CIntentParserResult): Int
96+
fun snips_nlu_engine_destroy_string(string: Pointer): Int
9797
}
9898
}

snips-nlu-ffi/python/snips-nlu-python-ffi/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ crate-type = ["cdylib"]
99

1010
[dependencies]
1111
libc = "0.2"
12-
snips-nlu-ffi = { git = "https://github.com/snipsco/snips-nlu-rs", tag = "0.55.2" }
12+
ffi-utils = { git = "https://github.com/snipsco/snips-utils-rs", rev = "b1f4af3" }
13+
snips-nlu-ffi = { git = "https://github.com/snipsco/snips-nlu-rs", tag = "0.56.0" }
Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
extern crate libc;
2+
extern crate ffi_utils;
23
extern crate snips_nlu_ffi;
34

4-
use snips_nlu_ffi::{NLURESULT, Opaque};
5+
use ffi_utils::SNIPS_RESULT;
6+
use snips_nlu_ffi::CSnipsNluEngine;
57

68
#[doc(hidden)]
79
#[macro_export]
@@ -17,10 +19,11 @@ macro_rules! export_c_symbol {
1719
}
1820
}
1921

20-
export_c_symbol!(ffi_nlu_engine_create_from_dir, fn nlu_engine_create_from_dir(root_dir: *const libc::c_char, client: *mut *const Opaque) -> NLURESULT);
21-
export_c_symbol!(ffi_nlu_engine_create_from_zip, fn nlu_engine_create_from_zip(zip: *const libc::c_uchar, zip_size: libc::c_uint, client: *mut *const Opaque) -> NLURESULT);
22-
export_c_symbol!(ffi_nlu_engine_run_parse_into_json, fn nlu_engine_run_parse_into_json(client: *const Opaque, input: *const libc::c_char, result_json: *mut *const libc::c_char) -> NLURESULT);
23-
export_c_symbol!(ffi_nlu_engine_get_last_error, fn nlu_engine_get_last_error(error: *mut *const libc::c_char) -> NLURESULT);
24-
export_c_symbol!(ffi_nlu_engine_destroy_string, fn nlu_engine_destroy_string(string: *mut libc::c_char) -> NLURESULT);
25-
export_c_symbol!(ffi_nlu_engine_destroy_client, fn nlu_engine_destroy_client(client: *mut Opaque) -> NLURESULT);
26-
export_c_symbol!(ffi_nlu_engine_get_model_version, fn nlu_engine_get_model_version(version: *mut *const libc::c_char) -> NLURESULT);
22+
export_c_symbol!(ffi_snips_nlu_engine_create_from_dir, fn snips_nlu_engine_create_from_dir(root_dir: *const libc::c_char, client: *mut *const CSnipsNluEngine) -> SNIPS_RESULT);
23+
export_c_symbol!(ffi_snips_nlu_engine_create_from_file, fn snips_nlu_engine_create_from_file(file_path: *const libc::c_char, client: *mut *const CSnipsNluEngine) -> SNIPS_RESULT);
24+
export_c_symbol!(ffi_snips_nlu_engine_create_from_zip, fn snips_nlu_engine_create_from_zip(zip: *const libc::c_uchar, zip_size: libc::c_uint, client: *mut *const CSnipsNluEngine) -> SNIPS_RESULT);
25+
export_c_symbol!(ffi_snips_nlu_engine_run_parse_into_json, fn snips_nlu_engine_run_parse_into_json(client: *const CSnipsNluEngine, input: *const libc::c_char, result_json: *mut *const libc::c_char) -> SNIPS_RESULT);
26+
export_c_symbol!(ffi_snips_nlu_engine_get_last_error, fn snips_nlu_engine_get_last_error(error: *mut *const libc::c_char) -> SNIPS_RESULT);
27+
export_c_symbol!(ffi_snips_nlu_engine_destroy_string, fn snips_nlu_engine_destroy_string(string: *mut libc::c_char) -> SNIPS_RESULT);
28+
export_c_symbol!(ffi_snips_nlu_engine_destroy_client, fn snips_nlu_engine_destroy_client(client: *mut CSnipsNluEngine) -> SNIPS_RESULT);
29+
export_c_symbol!(ffi_snips_nlu_engine_get_model_version, fn snips_nlu_engine_get_model_version(version: *mut *const libc::c_char) -> SNIPS_RESULT);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.55.2
1+
0.56.0

0 commit comments

Comments
 (0)