alexa_modelbuilder 0.1.2 → 0.2.0

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: 1aa68d014752e349a5a387078b96e7e833bf7744
4
- data.tar.gz: 6bb3c902a292134e5319cb16158acf22033ecdbb
3
+ metadata.gz: 3964950c1bac79477d333d79a940d018b2697c03
4
+ data.tar.gz: b540e483aaf40441a6d29f5d84c4ec6809d23257
5
5
  SHA512:
6
- metadata.gz: 52b6432da85a1b574acf6b75d8514f9096189cdb0ca36dbf7bb80ddf12b385601c88b67d5223f97899bda7d4bdb59ad89c2d58aabf4c35f0de938e0215bebda7
7
- data.tar.gz: 973a020fe1d82fdfb426363e5757249a5ae08fb38d09138d7173c3e6e459da2dd02f284cabc4e19591447a9d02d9e18e21b39689da009af4fb5fbdd238cd338f
6
+ metadata.gz: 725df2b477659f1d4de2a0f68e25e4846422a1ee7f5fe79e4631f1441886c24ccf7883e1f38fede62cf1829ab7c252f4717ac52aae26b056c71bf7afb9ab0505
7
+ data.tar.gz: f3e48e30463946a567b0de0ea0cf8ae3cdfc8853dd6d96a0151b50c5ed786d8219e5f696907f15116698d64515545151cbc781c750af4538d5b055778d4e31e3
checksums.yaml.gz.sig CHANGED
@@ -1,3 +1 @@
1
- R{!56����ټ+җ����?Ԣr�8$�r� s`=gGY٫h
2
- 4���7j9> zm�w��\�ǹb�����
3
- kϓ[?�S�>~Z�J�65=>. �
1
+ ��.�@P}���(�R�;��Ǐ���8���GluR!<��iH��R�\E[�5��R����}�g�}�d_����5
data.tar.gz.sig CHANGED
Binary file
@@ -9,12 +9,60 @@ require 'lineparser'
9
9
 
10
10
  class AlexaModelBuilder
11
11
 
12
- def initialize(s)
12
+ def initialize(s=nil)
13
13
 
14
- parse(s)
14
+ parse(s) if s
15
15
 
16
16
  end
17
17
 
18
+ def read(s)
19
+
20
+ h = JSON.parse(s, symbolize_names: true)
21
+
22
+ lm = h[:interactionModel][:languageModel]
23
+ lm[:invocationName]
24
+
25
+ out = []
26
+ out << 'invocation: ' + lm[:invocationName] + "\n"
27
+
28
+ lm[:intents].each do |intent|
29
+
30
+ out << intent[:name] + "\n"
31
+ intent[:samples].each do |utterance|
32
+ out << " " + utterance
33
+ end
34
+
35
+ if intent[:slots] and intent[:slots].any? then
36
+
37
+ out << "\n slots:"
38
+
39
+ intent[:slots].each do |slot|
40
+ out << " %s: %s" % [slot[:name], slot[:type]]
41
+ end
42
+
43
+ end
44
+
45
+ out << "\n" if intent[:samples].any?
46
+
47
+ end
48
+
49
+ if lm[:types] and lm[:types].any? then
50
+
51
+ out << "types:"
52
+
53
+ lm[:types].each do |type|
54
+ values = lm[:types][0][:values].map {|x| x[:name][:value] }.join(', ')
55
+ out << " %s: %s" % [type[:name], values]
56
+ end
57
+
58
+ end
59
+ out << "\n"
60
+
61
+ @s = out.join("\n")
62
+ #parse(@s)
63
+ self
64
+ end
65
+
18
66
  def to_h()
19
67
  @h
20
68
  end
@@ -22,6 +70,10 @@ class AlexaModelBuilder
22
70
  def to_json(pretty: true)
23
71
  pretty ? JSON.pretty_generate(@h) : @h.to_json
24
72
  end
73
+
74
+ def to_s()
75
+ @s
76
+ end
25
77
 
26
78
  private
27
79
 
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.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file