-
Notifications
You must be signed in to change notification settings - Fork 0
/
utterances_generator.rb
70 lines (56 loc) · 1.19 KB
/
utterances_generator.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
require 'active_support/all'
require 'json'
QUESTIONS = JSON.parse(File.read('speechAssets/q_and_a.json'))
def gen_intent str
"#{str} Intent".gsub(" ", "_").camelize
end
def gen_intent_schema
QUESTIONS.collect do |i|
{
"intent": gen_intent(i["q"])
}
end
end
# CountDownIntent when is christmas
# CountDownIntent when christmas is here
def gen_utterances
QUESTIONS.collect do |i|
gen_intent(i["q"]) + " " + i["q"]
end
end
def gen_claus_utterances
QUESTIONS.collect do |i|
gen_intent(i["q"]) + " claus " + i["q"]
end
end
def gen_js_code
QUESTIONS.collect do |i|
intent = gen_intent(i["q"])
answer = i["a"].gsub('"', "\"")
code = <<-EOF
"#{intent}": function (intent, session, response) {
response.tellWithCard("#{answer}", "#{answer}", "#{answer}");
},
EOF
end
end
def gen_docs
QUESTIONS.collect { |i| "Alexa ask Santa " + i["q"] }
end
puts ""
puts "Generating Intent Schema"
puts ""
puts gen_intent_schema.to_json.gsub("[", "").gsub("]", "")
puts ""
puts "Generating Utterances"
puts ""
puts gen_utterances
puts gen_claus_utterances
puts ""
puts "Generating JS Code"
puts ""
puts gen_js_code
puts ""
puts "Generating Docs"
puts ""
puts gen_docs