Skip to content

Commit

Permalink
Merge pull request #39 from snipsco/release/0.54.2
Browse files Browse the repository at this point in the history
Release 0.54.2
  • Loading branch information
Adrien Ball authored Apr 10, 2018
2 parents af346f0 + a00b595 commit 35241c3
Show file tree
Hide file tree
Showing 23 changed files with 488 additions and 97 deletions.
14 changes: 10 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# Changelog
All notable changes to this project will be documented in this file.

## [Unreleased]
## [0.54.2] - 2018-04-10

### Added
- Examples for builtin entities in all languages
- Japanese support for all builtin entities

### Fixed
- Issue with the entity kinds order used in BuiltinEntityParser

## [0.54.1] - 2018-04-03

Expand All @@ -15,6 +22,5 @@ All notable changes to this project will be documented in this file.
### Modified
- Updated Rustling ontoloty to `0.16.4`


[Unreleased]: https://github.com/snipsco/snips-nlu-ontology/compare/0.54.1...HEAD
[0.54.1]: https://github.com/snipsco/snips-nlu-ontology/compare/0.54.0...0.54.1
[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
41 changes: 24 additions & 17 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,57 +23,64 @@ Supported languages
+----------+------------+
| French | fr |
+----------+------------+
| Korean | ko |
+----------+------------+
| Japanese | ja |
+----------+------------+
| Korean | ko |
+----------+------------+

Supported builtin entities
--------------------------

+---------------+---------------------+---------------------+
| Entity | Identifier | Supported languages |
+===============+=====================+=====================+
| AmountOfMoney | snips/amountOfMoney | | English |
| | | | French |
| | | | German |
| AmountOfMoney | snips/amountOfMoney | | German |
| | | | English |
| | | | Spanish |
| | | | French |
| | | | Japanese |
| | | | Korean |
+---------------+---------------------+---------------------+
| Time | snips/datetime | | English |
| Time | snips/datetime | | German |
| | | | English |
| | | | Spanish |
| | | | French |
| | | | Japanese |
| | | | Korean |
| | | | German |
+---------------+---------------------+---------------------+
| Duration | snips/duration | | English |
| Duration | snips/duration | | German |
| | | | English |
| | | | Spanish |
| | | | French |
| | | | Japanese |
| | | | Korean |
| | | | German |
+---------------+---------------------+---------------------+
| Number | snips/number | | English |
| Number | snips/number | | German |
| | | | English |
| | | | Spanish |
| | | | French |
| | | | Japanese |
| | | | Korean |
| | | | German |
+---------------+---------------------+---------------------+
| Ordinal | snips/ordinal | | English |
| Ordinal | snips/ordinal | | German |
| | | | English |
| | | | Spanish |
| | | | French |
| | | | Japanese |
| | | | Korean |
| | | | German |
+---------------+---------------------+---------------------+
| Percentage | snips/percentage | | English |
| Percentage | snips/percentage | | German |
| | | | English |
| | | | Spanish |
| | | | French |
| | | | German |
| | | | Japanese |
+---------------+---------------------+---------------------+
| Temperature | snips/temperature | | English |
| Temperature | snips/temperature | | German |
| | | | English |
| | | | Spanish |
| | | | French |
| | | | Japanese |
| | | | Korean |
| | | | German |
+---------------+---------------------+---------------------+

Results Examples
Expand Down
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.1"
version = "0.54.2"
group = "ai.snips"


Expand Down
1 change: 1 addition & 0 deletions platforms/snips-nlu-ontology-python/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
venv/
venv2/
venv3/
venv34/
venv35/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "snips-nlu-ontology-rs"
version = "0.54.1"
version = "0.54.2"
authors = ["Adrien Ball <[email protected]>"]

[dependencies]
libc = "0.2"
snips-nlu-ontology = { git = "https://github.com/snipsco/snips-nlu-ontology", tag = "0.54.1" }
snips-nlu-ontology-ffi-macros = { git = "https://github.com/snipsco/snips-nlu-ontology", tag = "0.54.1" }
snips-nlu-ontology-parsers-ffi-macros = { git = "https://github.com/snipsco/snips-nlu-ontology", tag = "0.54.1" }
snips-nlu-ontology = { 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.2" }
snips-nlu-ontology-parsers-ffi-macros = { git = "https://github.com/snipsco/snips-nlu-ontology", tag = "0.54.2" }

[lib]
name = "snips_nlu_ontology_rs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

from snips_nlu_ontology.builtin_entities import (
BuiltinEntityParser, get_all_languages, get_all_builtin_entities,
get_supported_entities, get_ontology_version)
get_supported_entities, get_ontology_version, get_builtin_entity_examples)
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.54.1
0.54.2
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

_ALL_LANGUAGES = None
_SUPPORTED_ENTITIES = dict()
_ENTITIES_EXAMPLES = dict()
_ALL_BUILTIN_ENTITIES = None
_ONTOLOGY_VERSION = None

Expand Down Expand Up @@ -75,6 +76,35 @@ def get_supported_entities(language):
return _SUPPORTED_ENTITIES[language]


def get_builtin_entity_examples(builtin_entity_kind, language):
"""Provides some examples of the builtin entity in the specified language
"""
global _ENTITIES_EXAMPLES

if not isinstance(builtin_entity_kind, str):
raise TypeError("Expected `builtin_entity_kind` to be of type 'str' "
"but found: %s" % type(builtin_entity_kind))
if not isinstance(language, str):
raise TypeError("Expected `language` to be of type 'str' but found: %s"
% type(language))

if builtin_entity_kind not in _ENTITIES_EXAMPLES:
_ENTITIES_EXAMPLES[builtin_entity_kind] = dict()

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(
builtin_entity_kind.encode("utf8"),
language.encode("utf8"), byref(ptr))
if exit_code:
raise ValueError("Something wrong happened while retrieving "
"builtin entity examples. See stderr.")
array = ptr.contents
_ENTITIES_EXAMPLES[builtin_entity_kind][language] = list(
array.data[i].decode("utf8") for i in range(array.size))
return _ENTITIES_EXAMPLES[builtin_entity_kind][language]


class BuiltinEntityParser(object):
"""Extract builtin entities
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from builtins import str

from snips_nlu_ontology.builtin_entities import (
get_all_languages, get_all_builtin_entities, get_supported_entities,
get_ontology_version)
get_all_languages, get_all_builtin_entities, get_builtin_entity_examples,
get_supported_entities, get_ontology_version)


class TestBuiltinEntities(unittest.TestCase):
Expand Down Expand Up @@ -39,3 +39,10 @@ def test_should_get_supported_builtin_entities(self):

def test_should_get_ontology_version(self):
get_ontology_version()

def test_should_get_builtin_entity_examples(self):
for language in get_all_languages():
for builtin_entity in get_supported_entities(language):
examples = get_builtin_entity_examples(builtin_entity,
language)
self.assertGreaterEqual(len(examples), 1)
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_should_parse_without_scope(self):
def test_should_parse_with_scope(self):
# Given
parser = BuiltinEntityParser("en")
scope = ["snips/temperature", "snips/number"]
scope = ["snips/duration", "snips/temperature"]

# When
res = parser.parse("Raise to sixty two", scope)
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.1"
version = "0.54.2"
authors = ["Adrien Ball <[email protected]>"]

[build-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion snips-nlu-ontology-ffi-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "snips-nlu-ontology-ffi-macros"
version = "0.54.1"
version = "0.54.2"
authors = [
"Kevin Lefevre <[email protected]>",
"Thibaut Lorrain <[email protected]>",
Expand Down
20 changes: 20 additions & 0 deletions snips-nlu-ontology-ffi-macros/src/builtin_entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,23 @@ pub fn get_supported_builtin_entities(
}
Ok(())
}

pub fn get_builtin_entity_examples(
builtin_entity_kind: *const libc::c_char,
language: *const libc::c_char,
results: *mut *const CStringArray,
) -> Result<()> {
let entity_kind_str = unsafe { CStr::from_ptr(builtin_entity_kind) }.to_str()?;
let entity_kind = BuiltinEntityKind::from_identifier(&*entity_kind_str)?;
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()
.map(|example| example.to_string())
.collect::<Vec<String>>();
let c_examples = CStringArray::from(examples);
unsafe {
*results = Box::into_raw(Box::new(c_examples));
}
Ok(())
}
9 changes: 9 additions & 0 deletions snips-nlu-ontology-ffi-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,14 @@ macro_rules! export_nlu_ontology_c_symbols {
) -> $crate::ffi_utils::CResult {
wrap!($crate::get_supported_builtin_entities(language, results))
}

#[no_mangle]
pub extern "C" fn nlu_ontology_builtin_entity_examples(
builtin_entity_kind: *const libc::c_char,
language: *const libc::c_char,
results: *mut *const $crate::CStringArray,
) -> $crate::ffi_utils::CResult {
wrap!($crate::get_builtin_entity_examples(builtin_entity_kind, language, results))
}
};
}
2 changes: 1 addition & 1 deletion snips-nlu-ontology-ffi-with-parsers/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "snips-nlu-ontology-ffi-with-parsers"
version = "0.54.1"
version = "0.54.2"
authors = ["Kevin Lefevre <[email protected]>"]

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion snips-nlu-ontology-ffi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "snips-nlu-ontology-ffi"
version = "0.54.1"
version = "0.54.2"
authors = ["Kevin Lefevre <[email protected]>"]

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion snips-nlu-ontology-parsers-ffi-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "snips-nlu-ontology-parsers-ffi-macros"
version = "0.54.1"
version = "0.54.2"
authors = ["Kevin Lefevre <[email protected]>"]

[dependencies]
Expand Down
4 changes: 2 additions & 2 deletions snips-nlu-ontology-parsers/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "snips-nlu-ontology-parsers"
version = "0.54.1"
version = "0.54.2"
authors = ["Kevin Lefevre <[email protected]>"]

[dependencies]
Expand All @@ -9,5 +9,5 @@ lazy_static = "1.0"
maplit = "1.0"
snips-nlu-utils = { git = "https://github.com/snipsco/snips-nlu-utils", tag = "0.6.0" }
regex = "0.2"
rustling-ontology = { git = "https://github.com/snipsco/rustling-ontology", tag = "0.16.4" }
rustling-ontology = { git = "https://github.com/snipsco/rustling-ontology", tag = "0.16.5" }
snips-nlu-ontology = { path = "../snips-nlu-ontology" }
Loading

0 comments on commit 35241c3

Please sign in to comment.