Skip to content
This repository was archived by the owner on May 6, 2022. It is now read-only.

Commit 001402a

Browse files
authored
fix(nlu): update NLU slot type to be a map with custom property names (#91)
BREAKING CHANGE: The NLU slot type was changed in version 5.0. This commit changes it back to what it was pre-5.0. slots will be a map, and the property names will be derived from the name given in the NLU metadata.
1 parent ddbb73c commit 001402a

File tree

11 files changed

+30834
-90
lines changed

11 files changed

+30834
-90
lines changed

README.md

Lines changed: 104 additions & 68 deletions
Large diffs are not rendered by default.

android/src/main/java/com/reactnativespokestack/SpokestackAdapter.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class SpokestackAdapter(sendFunc:(event: String, data: WritableMap) -> Unit):io.
3030
reactEvent.putString("confidence", result.confidence.toString())
3131

3232
// Slots is an array of slots, not a map
33-
val slots = Arguments.createArray()
34-
for ((_, slot) in result.slots) {
33+
val slots = Arguments.createMap()
34+
for ((name, slot) in result.slots) {
3535
val slotMap = Arguments.createMap()
3636
slotMap.putString("type", slot.type)
3737
slotMap.putString("rawValue", slot.rawValue.toString())
@@ -42,9 +42,9 @@ class SpokestackAdapter(sendFunc:(event: String, data: WritableMap) -> Unit):io.
4242
null -> slotMap.putNull("value")
4343
else -> slotMap.putString("value", slot.value.toString())
4444
}
45-
slots.pushMap(slotMap)
45+
slots.putMap(name, slotMap)
4646
}
47-
reactEvent.putArray("slots", slots)
47+
reactEvent.putMap("slots", slots)
4848
sendEvent("classify", reactEvent)
4949
}
5050

example/metro.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = {
1717
// We need to make sure that only one version is loaded for peerDependencies
1818
// So we blacklist them at the root, and alias them to the versions in example's node_modules
1919
resolver: {
20-
assetExts: defaults.assetExts.concat(['tflite', 'txt']),
20+
assetExts: defaults.assetExts.concat(['sjson', 'tflite', 'txt']),
2121
blacklistRE: blacklist(
2222
modules.map(
2323
(m) =>

example/models/metadata.sjson

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"domain": "minecraft",
3+
"intents": [
4+
{
5+
"name": "AMAZON.YesIntent",
6+
"description": "",
7+
"implicit_slots": [],
8+
"slots": []
9+
},
10+
{
11+
"name": "AMAZON.NoIntent",
12+
"description": "",
13+
"implicit_slots": [],
14+
"slots": []
15+
},
16+
{
17+
"name": "AMAZON.StopIntent",
18+
"description": "",
19+
"implicit_slots": [],
20+
"slots": []
21+
},
22+
{
23+
"name": "RecipeIntent",
24+
"description": "",
25+
"implicit_slots": [],
26+
"slots": [
27+
{
28+
"name": "Item",
29+
"capture_name": "Item",
30+
"description": "",
31+
"type": "entity",
32+
"facets": "{}"
33+
}
34+
]
35+
},
36+
{
37+
"name": "AMAZON.RepeatIntent",
38+
"description": "",
39+
"implicit_slots": [],
40+
"slots": []
41+
},
42+
{
43+
"name": "AMAZON.CancelIntent",
44+
"description": "",
45+
"implicit_slots": [],
46+
"slots": []
47+
},
48+
{
49+
"name": "AMAZON.FallbackIntent",
50+
"description": "",
51+
"implicit_slots": [],
52+
"slots": []
53+
},
54+
{
55+
"name": "AMAZON.HelpIntent",
56+
"description": "",
57+
"implicit_slots": [],
58+
"slots": []
59+
}
60+
],
61+
"tags": [
62+
"o",
63+
"b_Item",
64+
"i_Item"
65+
]
66+
}

0 commit comments

Comments
 (0)