alexa_modelbuilder 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +2 -2
- data/lib/alexa_modelbuilder.rb +66 -43
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a547500e95eeeadcec607967625ad47db8e74ae7
|
4
|
+
data.tar.gz: b83dd6487e2774444abbdb2df0594eccd939a872
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a61d11aee196ce8c44ef060395d77db5add8c9f270cb9d17650188228f0828b80ee39ea66dad5f9d94519131cda3b968875e8c0ffcd9240bf388dc12883ae8d6
|
7
|
+
data.tar.gz: cd26e6b949d90941f6f36feefcba5178a69fdee3a7ec7bdc61fd5d444414a78710e5f140b24dacccfa5214eb13a0f841d4e79555df9346fc11b88346ecc6b3c0
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
|
2
|
-
��
|
1
|
+
�m4�؍$sr���1��x��3�e���_0���X�k8Je��A���>�]�ֲ�T����a������g$Zy�l� }��}�9��f�d5r��>�!�]�]=im �Jː�Ĝ�y�&��0&��=���
|
2
|
+
� �&5'"�������%�m�����h�G��P�噞^���9�������$/�gZH���027����Sr���1V�g��I!s{�U�X��(�7���D�`�M�U2��
|
data/lib/alexa_modelbuilder.rb
CHANGED
@@ -80,11 +80,11 @@ class AlexaModelBuilder
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def to_h()
|
83
|
-
@
|
83
|
+
@interact_model
|
84
84
|
end
|
85
85
|
|
86
86
|
def to_json(pretty: true)
|
87
|
-
pretty ? JSON.pretty_generate(@
|
87
|
+
pretty ? JSON.pretty_generate(@interact_model) : @interact_model.to_json
|
88
88
|
end
|
89
89
|
|
90
90
|
def to_s()
|
@@ -95,21 +95,45 @@ class AlexaModelBuilder
|
|
95
95
|
|
96
96
|
def parse(lines)
|
97
97
|
|
98
|
-
|
98
|
+
puts 'inside parse' if @debug
|
99
|
+
|
100
|
+
interaction = [
|
99
101
|
[:root, 'invocation: :invocation', :invocation],
|
100
102
|
[:root, 'types: :types', :types],
|
101
103
|
[:types, /(.*)/, :type],
|
102
104
|
[:root, ':intent', :intent],
|
103
105
|
[:intent, ':utterance', :utterance],
|
104
|
-
[:intent,
|
106
|
+
[:intent, /slots:/, :slots],
|
105
107
|
[:slots, /(.*)/, :slot],
|
106
108
|
[:all, /#/, :comment]
|
107
109
|
]
|
108
110
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
111
|
+
a = %w(
|
112
|
+
vendorId
|
113
|
+
locale
|
114
|
+
name
|
115
|
+
summary
|
116
|
+
description
|
117
|
+
keywords
|
118
|
+
examplePhrases
|
119
|
+
testingInstructions
|
120
|
+
endpoint
|
121
|
+
)
|
122
|
+
|
123
|
+
|
124
|
+
manifest = a.map do |word|
|
125
|
+
x = word.gsub(/(?<=.)(?=[A-Z])/,'_').downcase
|
126
|
+
[:root, "%s: :%s" % [x,x], x.to_sym]
|
127
|
+
end
|
128
|
+
|
129
|
+
a2 = manifest + interaction
|
130
|
+
puts 'a2: ' + a2.inspect if @debug
|
131
|
+
lp = LineParser.new a2, debug: @debug
|
132
|
+
lp.parse lines
|
133
|
+
h = lp.to_h
|
134
|
+
puts 'h: ' + h.inspect if @debug
|
135
|
+
|
136
|
+
model = {
|
113
137
|
'interactionModel' => {
|
114
138
|
'languageModel' => {
|
115
139
|
'invocationName' => '',
|
@@ -119,65 +143,64 @@ class AlexaModelBuilder
|
|
119
143
|
}
|
120
144
|
}
|
121
145
|
|
122
|
-
lm =
|
123
|
-
lm['invocationName'] =
|
146
|
+
lm = model['interactionModel']['languageModel']
|
147
|
+
lm['invocationName'] = h[:invocation]
|
124
148
|
|
125
|
-
|
149
|
+
intents = h[:intent].map do |row|
|
126
150
|
|
127
|
-
|
151
|
+
name, value = row.is_a?(Hash) ? row.to_a.first : [row, {}]
|
152
|
+
intent = {'name' => name , 'samples' => value[:utterance] || [] }
|
128
153
|
|
129
|
-
|
154
|
+
slots = value[:slots]
|
130
155
|
|
131
|
-
|
156
|
+
if slots then
|
132
157
|
|
133
|
-
|
134
|
-
raw_slots = x[3].find {|x| x.first == :slots }
|
158
|
+
a = slots.is_a?(Array) ? value[:slots] : [slots]
|
135
159
|
|
136
|
-
|
137
|
-
|
138
|
-
intent['slots'] = raw_slots[3].map do |slot|
|
160
|
+
intent['slots'] = a.map do |slot|
|
139
161
|
|
140
|
-
name, type = slot
|
162
|
+
name, type = slot.split(/: */,2)
|
141
163
|
{'name' => name, 'type' => type, 'samples' => []}
|
142
164
|
|
143
|
-
end
|
165
|
+
end
|
166
|
+
|
144
167
|
end
|
145
168
|
|
146
169
|
intent
|
147
170
|
|
148
171
|
end
|
149
172
|
|
150
|
-
|
151
173
|
lm['intents'] = intents
|
152
174
|
|
153
|
-
|
175
|
+
if h[:types] then
|
154
176
|
|
155
|
-
|
177
|
+
(h[:types].is_a?(Array) ? h[:types] : [h[:types]]).map do |raw_type|
|
156
178
|
|
157
|
-
|
158
|
-
|
179
|
+
name, raw_val = raw_type.split(/: */)
|
180
|
+
values = raw_val.split(/, */)
|
159
181
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
182
|
+
types = {'name' => name, 'values' => []}
|
183
|
+
|
184
|
+
types['values'] = values.map do |raw_val|
|
185
|
+
|
186
|
+
name, raw_synonyms = raw_val.split(/ *\(/,2)
|
187
|
+
|
188
|
+
h2 = {'name' => {'value' => name }}
|
189
|
+
|
190
|
+
if raw_synonyms then
|
191
|
+
synonyms = raw_synonyms[0..-2].split(/, */)
|
192
|
+
h2['synonyms'] = synonyms
|
193
|
+
end
|
194
|
+
|
195
|
+
h2
|
196
|
+
end
|
175
197
|
|
176
|
-
|
198
|
+
lm['types'] = types
|
199
|
+
end
|
177
200
|
|
178
201
|
end
|
179
202
|
|
180
|
-
@
|
203
|
+
@interact_model = model
|
181
204
|
|
182
205
|
end
|
183
206
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alexa_modelbuilder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
EgZc9/Cpxo+WohlXR69qWm5QxX8PvdLu5ZjGD2OH5pBAPToJQyk9O8kZB9OdDMZT
|
31
31
|
tns=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2018-06-
|
33
|
+
date: 2018-06-30 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: lineparser
|
metadata.gz.sig
CHANGED
Binary file
|