Skip to content

Commit

Permalink
Merge pull request #46 from snipsco/release/0.55.0
Browse files Browse the repository at this point in the history
Release 0.55.0
  • Loading branch information
Kevin Lefèvre authored May 2, 2018
2 parents eb870ff + e6a67ee commit fc57e30
Show file tree
Hide file tree
Showing 24 changed files with 250 additions and 397 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changelog
All notable changes to this project will be documented in this file.

## [0.55.0] - 2018-05-02

### Changed
- Updated ffi signatures

## [0.54.3] - 2018-04-20

### Changed
Expand All @@ -27,6 +32,7 @@ All notable changes to this project will be documented in this file.
### Changed
- Updated Rustling ontology to `0.16.4`

[0.55.0]: https://github.com/snipsco/snips-nlu-ontology/compare/0.54.3...0.55.0
[0.54.3]: https://github.com/snipsco/snips-nlu-ontology/compare/0.54.2...0.54.3
[0.54.2]: https://github.com/snipsco/snips-nlu-ontology/compare/0.54.1...0.54.2
[0.54.1]: https://github.com/snipsco/snips-nlu-ontology/compare/0.54.0...0.54.1
2 changes: 1 addition & 1 deletion platforms/snips-nlu-ontology-kotlin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}
}

version = "0.54.3"
version = "0.55.0"
group = "ai.snips"


Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
[package]
name = "snips-nlu-ontology-rs"
version = "0.54.3"
version = "0.55.0"
authors = ["Adrien Ball <adrien.ball@snips.ai>"]

[dependencies]
failure = "0.1"
ffi-utils = { git = "https://github.com/snipsco/snips-utils-rs", rev = "b1f4af3" }
lazy_static = "1.0"
libc = "0.2"
snips-nlu-ontology = { 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.54.3" }
snips-nlu-ontology-parsers-ffi-macros = { git = "https://github.com/snipsco/snips-nlu-ontology", tag = "0.54.3" }
snips-nlu-ontology = { git = "https://github.com/snipsco/snips-nlu-ontology", tag = "0.55.0" }
snips-nlu-ontology-ffi-macros = { git = "https://github.com/snipsco/snips-nlu-ontology", tag = "0.55.0" }
snips-nlu-ontology-parsers-ffi-macros = { git = "https://github.com/snipsco/snips-nlu-ontology", tag = "0.55.0" }

[lib]
name = "snips_nlu_ontology_rs"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
#[macro_use]
extern crate failure;
#[macro_use]
extern crate lazy_static;
extern crate libc;
extern crate snips_nlu_ontology;
#[macro_use]
extern crate snips_nlu_ontology_ffi_macros;
#[macro_use]
extern crate snips_nlu_ontology_parsers_ffi_macros;
#[macro_use]
extern crate ffi_utils;

generate_error_handling!(snips_nlu_ontology_get_last_error);

export_nlu_ontology_c_symbols!();

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.54.3
0.55.0
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ def get_ontology_version():
"""Get the version of the ontology"""
global _ONTOLOGY_VERSION
if _ONTOLOGY_VERSION is None:
lib.nlu_ontology_version.restype = c_char_p
_ONTOLOGY_VERSION = lib.nlu_ontology_version().decode("utf8")
lib.snips_nlu_ontology_version.restype = c_char_p
_ONTOLOGY_VERSION = lib.snips_nlu_ontology_version().decode("utf8")
return _ONTOLOGY_VERSION


def get_all_languages():
"""Lists all the supported languages"""
global _ALL_LANGUAGES
if _ALL_LANGUAGES is None:
lib.nlu_ontology_supported_languages.restype = CStringArray
array = lib.nlu_ontology_supported_languages()
lib.snips_nlu_ontology_supported_languages.restype = CStringArray
array = lib.snips_nlu_ontology_supported_languages()
_ALL_LANGUAGES = set(
array.data[i].decode("utf8") for i in range(array.size))
return _ALL_LANGUAGES
Expand All @@ -44,8 +44,8 @@ def get_all_builtin_entities():
language"""
global _ALL_BUILTIN_ENTITIES
if _ALL_BUILTIN_ENTITIES is None:
lib.nlu_ontology_all_builtin_entities.restype = CStringArray
array = lib.nlu_ontology_all_builtin_entities()
lib.snips_nlu_ontology_all_builtin_entities.restype = CStringArray
array = lib.snips_nlu_ontology_all_builtin_entities()
_ALL_BUILTIN_ENTITIES = set(
array.data[i].decode("utf8") for i in range(array.size))
return _ALL_BUILTIN_ENTITIES
Expand All @@ -65,7 +65,7 @@ def get_supported_entities(language):

if language not in _SUPPORTED_ENTITIES:
with string_array_pointer(pointer(CStringArray())) as ptr:
exit_code = lib.nlu_ontology_supported_builtin_entities(
exit_code = lib.snips_nlu_ontology_supported_builtin_entities(
language.encode("utf8"), byref(ptr))
if exit_code:
raise ValueError("Something wrong happened while retrieving "
Expand Down Expand Up @@ -93,7 +93,7 @@ def get_builtin_entity_examples(builtin_entity_kind, language):

if language not in _ENTITIES_EXAMPLES[builtin_entity_kind]:
with string_array_pointer(pointer(CStringArray())) as ptr:
exit_code = lib.nlu_ontology_builtin_entity_examples(
exit_code = lib.snips_nlu_ontology_builtin_entity_examples(
builtin_entity_kind.encode("utf8"),
language.encode("utf8"), byref(ptr))
if exit_code:
Expand All @@ -118,15 +118,15 @@ def __init__(self, language):
" %s" % type(language))
self.language = language
self._parser = pointer(c_void_p())
exit_code = lib.nlu_ontology_create_builtin_entity_parser(
exit_code = lib.snips_nlu_ontology_create_builtin_entity_parser(
byref(self._parser), language.encode("utf8"))
if exit_code:
raise ImportError("Something wrong happened while creating the "
"intent parser. See stderr.")

def __del__(self):
if hasattr(self, '_parser'):
lib.nlu_ontology_destroy_builtin_entity_parser(self._parser)
lib.snips_nlu_ontology_destroy_builtin_entity_parser(self._parser)

def parse(self, text, scope=None):
"""Extract builtin entities from *text*
Expand Down Expand Up @@ -155,7 +155,7 @@ def parse(self, text, scope=None):
scope = byref(arr)

with string_pointer(c_char_p()) as ptr:
exit_code = lib.nlu_ontology_extract_entities_json(
exit_code = lib.snips_nlu_ontology_extract_entities_json(
self._parser, text.encode("utf8"), scope, byref(ptr))
if exit_code:
raise ValueError("Something wrong happened while extracting "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ def string_array_pointer(ptr):
try:
yield ptr
finally:
lib.nlu_ontology_destroy_string_array(ptr)
lib.snips_nlu_ontology_destroy_string_array(ptr)


@contextmanager
def string_pointer(ptr):
try:
yield ptr
finally:
lib.nlu_ontology_destroy_string(ptr)
lib.snips_nlu_ontology_destroy_string(ptr)


class CStringArray(Structure):
Expand Down
2 changes: 1 addition & 1 deletion snips-nlu-ontology-doc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "snips-nlu-ontology-doc"
version = "0.54.3"
version = "0.55.0"
authors = ["Adrien Ball <adrien.ball@snips.ai>"]

[build-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions snips-nlu-ontology-ffi-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
name = "snips-nlu-ontology-ffi-macros"
version = "0.54.3"
version = "0.55.0"
authors = [
"Kevin Lefevre <kevin.lefevre@snips.ai>",
"Thibaut Lorrain <thibaut.lorrain@snips.ai>",
]

[dependencies]
snips-nlu-ontology = { path = "../snips-nlu-ontology" }
failure = "0.1"
ffi-utils = { git = "https://github.com/snipsco/snips-utils-rs", rev = "b1f4af3" }
lazy_static = "1.0"
libc = "0.2"
serde = "1.0"
Expand Down
30 changes: 15 additions & 15 deletions snips-nlu-ontology-ffi-macros/src/builtin_entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::str::FromStr;
use libc;

use errors::*;
use ffi_utils::CStringArray;
use ffi_utils::{CStringArray, CReprOf, RawPointerConverter};
use snips_nlu_ontology::{BuiltinEntityKind, Language};

#[repr(C)]
Expand All @@ -22,11 +22,11 @@ pub struct CBuiltinEntity {
}

impl From<::BuiltinEntity> for CBuiltinEntity {
fn from(e: ::BuiltinEntity) -> CBuiltinEntity {
fn from(e: ::BuiltinEntity) -> Self {
Self {
entity: ::CSlotValue::from(e.entity),
entity_kind: CString::new(e.entity_kind.identifier()).unwrap().into_raw(),
value: CString::new(e.value).unwrap().into_raw(), // String can not contains 0
value: CString::new(e.value).unwrap().into_raw(),
range_start: e.range.start as libc::int32_t,
range_end: e.range.end as libc::int32_t,
}
Expand All @@ -35,8 +35,8 @@ impl From<::BuiltinEntity> for CBuiltinEntity {

impl Drop for CBuiltinEntity {
fn drop(&mut self) {
let _ = unsafe { CString::from_raw(self.value as *mut libc::c_char) };
let _ = unsafe { CString::from_raw(self.entity_kind as *mut libc::c_char) };
take_back_c_string!(self.value);
take_back_c_string!(self.entity_kind);
}
}

Expand All @@ -47,8 +47,8 @@ pub struct CBuiltinEntityArray {
pub size: libc::int32_t, // Note: we can't use `libc::size_t` because it's not supported by JNA
}

impl CBuiltinEntityArray {
pub fn from(input: Vec<CBuiltinEntity>) -> Self {
impl From<Vec<CBuiltinEntity>> for CBuiltinEntityArray {
fn from(input: Vec<CBuiltinEntity>) -> Self {
Self {
size: input.len() as libc::int32_t,
data: Box::into_raw(input.into_boxed_slice()) as *const CBuiltinEntity,
Expand Down Expand Up @@ -81,7 +81,7 @@ pub fn all_builtin_entities() -> CStringArray {
.iter()
.map(|l| l.identifier().to_string())
.map(|l| CString::new(l).unwrap().into_raw() as *const libc::c_char)
.collect::<Vec<*const libc::c_char>>()
.collect::<Vec<_>>()
.into_boxed_slice()
)
};
Expand All @@ -103,10 +103,10 @@ pub fn get_supported_builtin_entities(
.iter()
.filter(|e| e.supported_languages().contains(&language))
.map(|e| e.identifier().to_string())
.collect::<Vec<String>>();
let c_entities = CStringArray::from(entities);
.collect::<Vec<_>>();
let c_entities = CStringArray::c_repr_of(entities)?.into_raw_pointer();
unsafe {
*results = Box::into_raw(Box::new(c_entities));
*results = c_entities;
}
Ok(())
}
Expand All @@ -121,12 +121,12 @@ pub fn get_builtin_entity_examples(
let language_str = unsafe { CStr::from_ptr(language) }.to_str()?;
let language = Language::from_str(&*language_str.to_uppercase())?;
let examples = entity_kind.examples(language)
.iter()
.into_iter()
.map(|example| example.to_string())
.collect::<Vec<String>>();
let c_examples = CStringArray::from(examples);
.collect::<Vec<_>>();
let c_examples = CStringArray::c_repr_of(examples)?.into_raw_pointer();
unsafe {
*results = Box::into_raw(Box::new(c_examples));
*results = c_examples;
}
Ok(())
}
32 changes: 0 additions & 32 deletions snips-nlu-ontology-ffi-macros/src/failure_ext.rs

This file was deleted.

Loading

0 comments on commit fc57e30

Please # to comment.