Skip to content

Commit

Permalink
Merge pull request #40 from snipsco/release/0.56.0
Browse files Browse the repository at this point in the history
Release 0.56.0
  • Loading branch information
Kevin Lefèvre authored May 3, 2018
2 parents 6a48f86 + 09e8ce7 commit 1f1d0ef
Show file tree
Hide file tree
Showing 23 changed files with 290 additions and 340 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ matrix:
- TOXENV=py36
- PYTHON_TESTS=true
- os: osx
osx_image: xcode9.2
osx_image: xcode9.3
language: generic
env:
- MACOS_SWIFT_TESTS=true
- os: osx
osx_image: xcode9.2
osx_image: xcode9.3
language: generic
env:
- IOS_SWIFT_TESTS=true
Expand Down Expand Up @@ -61,7 +61,7 @@ before_install: . ./.travis/before_install.sh

install: ./.travis/install.sh

script: travis_wait 30 bash ./.travis/test.sh
script: travis_wait 40 bash ./.travis/test.sh

git:
depth: 10
2 changes: 2 additions & 0 deletions .travis/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ if [ "${MACOS_SWIFT_TESTS}" == "true" ]; then
-workspace SnipsNlu.xcworkspace \
-scheme SnipsNlu-macOS \
TARGET_BUILD_TYPE=debug \
SNIPS_USE_LOCAL=1 \
clean \
test \
| xcpretty
Expand All @@ -58,6 +59,7 @@ if [ "${IOS_SWIFT_TESTS}" == "true" ]; then
-scheme SnipsNlu-iOS \
-destination 'platform=iOS Simulator,name=iPhone 8,OS=latest' \
TARGET_BUILD_TYPE=debug \
SNIPS_USE_LOCAL=1 \
clean \
test \
| xcpretty
Expand Down
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Changelog
All notable changes to this project will be documented in this file.

## [0.56.0] - 2018-05-03
### Changed
- Change ffi signatures
- Update swift project to Xcode 9.3
- Bump snips-nlu-ontology to `0.55.0`

## [0.55.2] - 2018-04-20
### Changed
- Make configurations and pipeline objects public
Expand Down Expand Up @@ -30,6 +36,7 @@ All notable changes to this project will be documented in this file.
- Rename python package to `snips_nlu_rust`


[0.56.0]: https://github.com/snipsco/snips-nlu-rs/compare/0.55.2...0.56.0
[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
[0.55.0]: https://github.com/snipsco/snips-nlu-rs/compare/0.54.0...0.55.0
5 changes: 3 additions & 2 deletions snips-nlu-ffi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
[package]
name = "snips-nlu-ffi"
version = "0.55.2"
version = "0.56.0"
authors = [
"Kevin Lefevre <kevin.lefevre@snips.ai>",
"Thibaut Lorrain <thibaut.lorrain@snips.ai>"
]

[dependencies]
ffi-utils = { git = "https://github.com/snipsco/snips-utils-rs", rev = "b1f4af3" }
snips-nlu-lib = { path = "../snips-nlu-lib" }
snips-nlu-ontology-ffi-macros = { git = "https://github.com/snipsco/snips-nlu-ontology", tag = "0.54.3" }
snips-nlu-ontology-ffi-macros = { git = "https://github.com/snipsco/snips-nlu-ontology", tag = "0.55.0" }
failure = "0.1"
lazy_static = "1.0"
libc = "0.2"
Expand Down
94 changes: 47 additions & 47 deletions snips-nlu-ffi/c/libsnips_nlu.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,33 @@
extern "C" {
#endif

typedef enum CPrecision {
APPROXIMATE = 0,
EXACT = 1,
} CPrecision;

typedef enum CGrain {
YEAR = 0,
QUARTER = 1,
MONTH = 2,
WEEK = 3,
DAY = 4,
HOUR = 5,
MINUTE = 6,
SECOND = 7,
} CGrain;

typedef enum CSlotValueType {
CUSTOM = 1,
NUMBER = 2,
ORDINAL = 3,
INSTANTTIME = 4,
TIMEINTERVAL = 5,
AMOUNTOFMONEY = 6,
TEMPERATURE = 7,
DURATION = 8,
PERCENTAGE = 9,
} CSlotValueType;
typedef enum SNIPS_PRECISION {
SNIPS_PRECISION_APPROXIMATE = 0,
SNIPS_PRECISION_EXACT = 1,
} SNIPS_PRECISION;

typedef enum SNIPS_GRAIN {
SNIPS_GRAIN_YEAR = 0,
SNIPS_GRAIN_QUARTER = 1,
SNIPS_GRAIN_MONTH = 2,
SNIPS_GRAIN_WEEK = 3,
SNIPS_GRAIN_DAY = 4,
SNIPS_GRAIN_HOUR = 5,
SNIPS_GRAIN_MINUTE = 6,
SNIPS_GRAIN_SECOND = 7,
} SNIPS_GRAIN;

typedef enum SNIPS_SLOT_VALUE_TYPE {
SNIPS_SLOT_VALUE_TYPE_CUSTOM = 1,
SNIPS_SLOT_VALUE_TYPE_NUMBER = 2,
SNIPS_SLOT_VALUE_TYPE_ORDINAL = 3,
SNIPS_SLOT_VALUE_TYPE_INSTANTTIME = 4,
SNIPS_SLOT_VALUE_TYPE_TIMEINTERVAL = 5,
SNIPS_SLOT_VALUE_TYPE_AMOUNTOFMONEY = 6,
SNIPS_SLOT_VALUE_TYPE_TEMPERATURE = 7,
SNIPS_SLOT_VALUE_TYPE_DURATION = 8,
SNIPS_SLOT_VALUE_TYPE_PERCENTAGE = 9,
} SNIPS_SLOT_VALUE_TYPE;

typedef double CNumberValue;

Expand All @@ -41,8 +41,8 @@ typedef long COrdinalValue;

typedef struct CInstantTimeValue {
char *const value;
CGrain grain;
CPrecision precision;
SNIPS_GRAIN grain;
SNIPS_PRECISION precision;
} CInstantTimeValue;

typedef struct CTimeIntervalValue {
Expand All @@ -52,7 +52,7 @@ typedef struct CTimeIntervalValue {

typedef struct CAmountOfMoneyValue {
float value;
CPrecision precision;
SNIPS_PRECISION precision;
char *const unit;
} CAmountOfMoneyValue;

Expand All @@ -70,11 +70,11 @@ typedef struct CDurationValue {
long hours;
long minutes;
long seconds;
CPrecision precision;
SNIPS_PRECISION precision;
} CDurationValue;

typedef struct CSlotValue {
CSlotValueType value_type;
SNIPS_SLOT_VALUE_TYPE value_type;
/**
* Points to either a char *const, a CNumberValue, a COrdinalValue,
* a CInstantTimeValue, a CTimeIntervalValue, a CAmountOfMoneyValue,
Expand Down Expand Up @@ -108,32 +108,32 @@ typedef struct CIntentParserResult{
CSlotList *const slots;
} CIntentParserResult;

typedef struct Opaque Opaque;
typedef struct CSnipsNluEngine CSnipsNluEngine;

typedef enum NLURESULT {
KO = 0,
OK = 1,
} NLURESULT;
typedef enum SNIPS_RESULT {
SNIPS_RESULT_OK = 0,
SNIPS_RESULT_KO = 1,
} SNIPS_RESULT;

NLURESULT nlu_engine_create_from_file(char const* file_path, Opaque** client);
SNIPS_RESULT snips_nlu_engine_create_from_file(char const* file_path, CSnipsNluEngine** client);

NLURESULT nlu_engine_create_from_dir(char const* root_dir, Opaque** client);
SNIPS_RESULT snips_nlu_engine_create_from_dir(char const* root_dir, CSnipsNluEngine** client);

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

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

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

NLURESULT nlu_engine_destroy_string(char* string);
SNIPS_RESULT snips_nlu_engine_destroy_string(char* string);

NLURESULT nlu_engine_destroy_client(Opaque* client);
SNIPS_RESULT snips_nlu_engine_destroy_client(CSnipsNluEngine* client);

NLURESULT nlu_engine_destroy_result(CIntentParserResult* result);
SNIPS_RESULT snips_nlu_engine_destroy_result(CIntentParserResult* result);

NLURESULT nlu_engine_get_last_error(char **error);
SNIPS_RESULT snips_nlu_engine_get_last_error(char **error);

NLURESULT nlu_engine_get_model_version(char **version);
SNIPS_RESULT snips_nlu_engine_get_model_version(char **version);

#ifdef __cplusplus
}
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.2"
version = "0.56.0"
group = "ai.snips"

repositories {
Expand Down
46 changes: 23 additions & 23 deletions snips-nlu-ffi/kotlin/src/main/kotlin/ai/snips/nlu/NluEngine.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,66 +16,66 @@ class NluEngine private constructor(clientBuilder: () -> Pointer) : Closeable {

companion object {
private fun parseError(returnCode: Int) {
if (returnCode != 1) {
if (returnCode != 0) {
PointerByReference().apply {
LIB.nlu_engine_get_last_error(this)
LIB.snips_nlu_engine_get_last_error(this)
throw RuntimeException(value.getString(0).apply {
LIB.nlu_engine_destroy_string(value)
LIB.snips_nlu_engine_destroy_string(value)
})
}
}
}

@JvmStatic
fun modelVersion(): String = PointerByReference().run {
parseError(LIB.nlu_engine_get_model_version(this))
value.getString(0).apply { LIB.nlu_engine_destroy_string(value) }
parseError(LIB.snips_nlu_engine_get_model_version(this))
value.getString(0).apply { LIB.snips_nlu_engine_destroy_string(value) }
}
}

constructor(assistant: File) :
this({
PointerByReference().apply {
if (assistant.isDirectory) {
parseError(LIB.nlu_engine_create_from_dir(assistant.absolutePath.toPointer(), this))
parseError(LIB.snips_nlu_engine_create_from_dir(assistant.absolutePath.toPointer(), this))
} else {
parseError(LIB.nlu_engine_create_from_file(assistant.absolutePath.toPointer(), this))
parseError(LIB.snips_nlu_engine_create_from_file(assistant.absolutePath.toPointer(), this))
}
}.value
})

constructor(data: ByteArray) :
this({
PointerByReference().apply {
parseError(LIB.nlu_engine_create_from_zip(data, data.size, this))
parseError(LIB.snips_nlu_engine_create_from_zip(data, data.size, this))
}.value
})


val client: Pointer = clientBuilder()

override fun close() {
LIB.nlu_engine_destroy_client(client)
LIB.snips_nlu_engine_destroy_client(client)
}

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

fun parseIntoJson(input: String): String =
PointerByReference().apply {
parseError(LIB.nlu_engine_run_parse_into_json(client, input.toPointer(), this))
parseError(LIB.snips_nlu_engine_run_parse_into_json(client, input.toPointer(), this))
}.value.let {
it.readString().apply {
LIB.nlu_engine_destroy_string(it)
LIB.snips_nlu_engine_destroy_string(it)
}
}

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

fun nlu_engine_get_model_version(version: PointerByReference): Int
fun nlu_engine_create_from_file(file_path: Pointer, pointer: PointerByReference): Int
fun nlu_engine_create_from_dir(root_dir: Pointer, pointer: PointerByReference): Int
fun nlu_engine_create_from_zip(data: ByteArray, data_size: Int, pointer: PointerByReference): Int
fun nlu_engine_run_parse(client: Pointer, input: Pointer, result: PointerByReference): Int
fun nlu_engine_run_parse_into_json(client: Pointer, input: Pointer, result: PointerByReference): Int
fun nlu_engine_get_last_error(error: PointerByReference): Int
fun nlu_engine_destroy_client(client: Pointer): Int
fun nlu_engine_destroy_result(result: CIntentParserResult): Int
fun nlu_engine_destroy_string(string: Pointer): Int
fun snips_nlu_engine_get_model_version(version: PointerByReference): Int
fun snips_nlu_engine_create_from_file(file_path: Pointer, pointer: PointerByReference): Int
fun snips_nlu_engine_create_from_dir(root_dir: Pointer, pointer: PointerByReference): Int
fun snips_nlu_engine_create_from_zip(data: ByteArray, data_size: Int, pointer: PointerByReference): Int
fun snips_nlu_engine_run_parse(client: Pointer, input: Pointer, result: PointerByReference): Int
fun snips_nlu_engine_run_parse_into_json(client: Pointer, input: Pointer, result: PointerByReference): Int
fun snips_nlu_engine_get_last_error(error: PointerByReference): Int
fun snips_nlu_engine_destroy_client(client: Pointer): Int
fun snips_nlu_engine_destroy_result(result: CIntentParserResult): Int
fun snips_nlu_engine_destroy_string(string: Pointer): Int
}
}
3 changes: 2 additions & 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,5 @@ crate-type = ["cdylib"]

[dependencies]
libc = "0.2"
snips-nlu-ffi = { git = "https://github.com/snipsco/snips-nlu-rs", tag = "0.55.2" }
ffi-utils = { git = "https://github.com/snipsco/snips-utils-rs", rev = "b1f4af3" }
snips-nlu-ffi = { git = "https://github.com/snipsco/snips-nlu-rs", tag = "0.56.0" }
19 changes: 11 additions & 8 deletions snips-nlu-ffi/python/snips-nlu-python-ffi/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
extern crate libc;
extern crate ffi_utils;
extern crate snips_nlu_ffi;

use snips_nlu_ffi::{NLURESULT, Opaque};
use ffi_utils::SNIPS_RESULT;
use snips_nlu_ffi::CSnipsNluEngine;

#[doc(hidden)]
#[macro_export]
Expand All @@ -17,10 +19,11 @@ macro_rules! export_c_symbol {
}
}

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);
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);
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);
export_c_symbol!(ffi_nlu_engine_get_last_error, fn nlu_engine_get_last_error(error: *mut *const libc::c_char) -> NLURESULT);
export_c_symbol!(ffi_nlu_engine_destroy_string, fn nlu_engine_destroy_string(string: *mut libc::c_char) -> NLURESULT);
export_c_symbol!(ffi_nlu_engine_destroy_client, fn nlu_engine_destroy_client(client: *mut Opaque) -> NLURESULT);
export_c_symbol!(ffi_nlu_engine_get_model_version, fn nlu_engine_get_model_version(version: *mut *const libc::c_char) -> NLURESULT);
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);
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);
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);
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);
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);
export_c_symbol!(ffi_snips_nlu_engine_destroy_string, fn snips_nlu_engine_destroy_string(string: *mut libc::c_char) -> SNIPS_RESULT);
export_c_symbol!(ffi_snips_nlu_engine_destroy_client, fn snips_nlu_engine_destroy_client(client: *mut CSnipsNluEngine) -> SNIPS_RESULT);
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);
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.2
0.56.0
Loading

0 comments on commit 1f1d0ef

Please sign in to comment.