alexa_modelbuilder 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3381dc4cce19a37241b13d42f67cbe89b6d712b8
4
- data.tar.gz: 721badd3aaf8e564a74ba5f273242a44cebd3918
3
+ metadata.gz: 1aa68d014752e349a5a387078b96e7e833bf7744
4
+ data.tar.gz: 6bb3c902a292134e5319cb16158acf22033ecdbb
5
5
  SHA512:
6
- metadata.gz: 175d0a8a904520aabdd27834996cb5976e82b1c9d85885f6abe23dcd4c0d3d075350aa3a41730e1241dafe9e7a5418f359db6fd2f28df91b3981f2b49a52f44b
7
- data.tar.gz: 1c52c23db717c4e7eadc4b4366c59a9494e7c44a9ec044edd634cf01adf52f5292948fb8f2937f197ae8ece2cf8b9e257c6dfdc0bf4c07054972c7c0c17e19c7
6
+ metadata.gz: 52b6432da85a1b574acf6b75d8514f9096189cdb0ca36dbf7bb80ddf12b385601c88b67d5223f97899bda7d4bdb59ad89c2d58aabf4c35f0de938e0215bebda7
7
+ data.tar.gz: 973a020fe1d82fdfb426363e5757249a5ae08fb38d09138d7173c3e6e459da2dd02f284cabc4e19591447a9d02d9e18e21b39689da009af4fb5fbdd238cd338f
checksums.yaml.gz.sig CHANGED
Binary file
@@ -9,13 +9,19 @@ require 'lineparser'
9
9
 
10
10
  class AlexaModelBuilder
11
11
 
12
- attr_reader :to_h, :to_json
13
-
14
12
  def initialize(s)
15
13
 
16
14
  parse(s)
17
15
 
18
16
  end
17
+
18
+ def to_h()
19
+ @h
20
+ end
21
+
22
+ def to_json(pretty: true)
23
+ pretty ? JSON.pretty_generate(@h) : @h.to_json
24
+ end
19
25
 
20
26
  private
21
27
 
@@ -53,9 +59,23 @@ class AlexaModelBuilder
53
59
  intents = raw_intents.map do |x|
54
60
 
55
61
  raw_utterances = x[3].select {|y| y.first == :utterance}
62
+
56
63
  utterances = raw_utterances.map {|z| z[2].first.rstrip }
57
64
 
58
- {'name' => x[1].values.first, 'samples' => utterances }
65
+ intent = {'name' => x[1].values.first, 'samples' => utterances }
66
+ raw_slots = x[3].find {|x| x.first == :slots }
67
+
68
+ if raw_slots then
69
+
70
+ intent['slots'] = raw_slots[3].map do |slot|
71
+
72
+ name, type = slot[2].first.split(/: */,2)
73
+ {'name' => name, 'type' => type, 'samples' => []}
74
+
75
+ end
76
+ end
77
+
78
+ intent
59
79
 
60
80
  end
61
81
 
@@ -70,16 +90,13 @@ class AlexaModelBuilder
70
90
  values = raw_val.split(/, */)
71
91
 
72
92
  types = {'name' => name, 'values' => []}
73
- types['values'] = values.map do |x|
74
- {'name' => {'value' => x }}
75
- end
93
+ types['values'] = values.map {|x|{'name' => {'value' => x }} }
76
94
 
77
95
  lm['types'] = types
78
96
 
79
97
  end
80
98
 
81
- @to_h = h
82
- @to_json = h.to_json
99
+ @h = h
83
100
 
84
101
  end
85
102
 
data.tar.gz.sig CHANGED
@@ -1 +1 @@
1
- ����<����׸NZd3 �t��RNXY/�m~r4Nے����v'�á$7SR�1��G�7�RF86�=��<�᧔��`��oX�����\�}�{Q�N|���X��cAxnZF���[��F�&A�����;�I5�Γc���D�����h�B1=�ZX�ٻ���8O?!�L�'de���Zeź�W���@D�t�Ȧ%����,g��l���k!¸�I8&���L^X2D{(Y
1
+ Z�����/����t��).(�eK��ELp5!���?i)WA(]��r���od��*r��jbi��m�#-���xXkc}S
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.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file