ruby_speech 2.3.1-java → 3.0.1-java
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 +5 -5
- data/.gitignore +1 -0
- data/.hound.yml +2 -0
- data/.travis.yml +25 -9
- data/CHANGELOG.md +19 -1
- data/README.md +14 -15
- data/Rakefile +2 -0
- data/ext/ruby_speech/RubySpeechGRXMLMatcher.java +17 -12
- data/ext/ruby_speech/RubySpeechService.java +1 -1
- data/ext/ruby_speech/extconf.rb +1 -1
- data/lib/ruby_speech/generic_element.rb +2 -2
- data/lib/ruby_speech/grxml/builtins.rb +18 -11
- data/lib/ruby_speech/grxml/grammar.rb +26 -4
- data/lib/ruby_speech/grxml/matcher.rb +2 -2
- data/lib/ruby_speech/grxml.rb +2 -0
- data/lib/ruby_speech/nlsml/builder.rb +2 -1
- data/lib/ruby_speech/nlsml/document.rb +5 -0
- data/lib/ruby_speech/ruby_speech.jar +0 -0
- data/lib/ruby_speech/ssml/break.rb +1 -2
- data/lib/ruby_speech/ssml/element.rb +13 -1
- data/lib/ruby_speech/ssml/mark.rb +0 -1
- data/lib/ruby_speech/ssml/prosody.rb +8 -5
- data/lib/ruby_speech/version.rb +1 -1
- data/ruby_speech.gemspec +13 -8
- data/spec/ruby_speech/grxml/builtins_spec.rb +80 -71
- data/spec/ruby_speech/grxml/grammar_spec.rb +168 -34
- data/spec/ruby_speech/grxml/item_spec.rb +33 -33
- data/spec/ruby_speech/grxml/match_spec.rb +1 -1
- data/spec/ruby_speech/grxml/matcher_spec.rb +103 -59
- data/spec/ruby_speech/grxml/max_match_spec.rb +2 -2
- data/spec/ruby_speech/grxml/no_match_spec.rb +2 -2
- data/spec/ruby_speech/grxml/one_of_spec.rb +6 -6
- data/spec/ruby_speech/grxml/potential_match_spec.rb +2 -2
- data/spec/ruby_speech/grxml/rule_spec.rb +17 -17
- data/spec/ruby_speech/grxml/ruleref_spec.rb +10 -10
- data/spec/ruby_speech/grxml/tag_spec.rb +5 -5
- data/spec/ruby_speech/grxml/token_spec.rb +7 -7
- data/spec/ruby_speech/grxml_spec.rb +25 -25
- data/spec/ruby_speech/nlsml_spec.rb +58 -10
- data/spec/ruby_speech/ssml/audio_spec.rb +19 -19
- data/spec/ruby_speech/ssml/break_spec.rb +42 -22
- data/spec/ruby_speech/ssml/desc_spec.rb +7 -7
- data/spec/ruby_speech/ssml/emphasis_spec.rb +21 -21
- data/spec/ruby_speech/ssml/mark_spec.rb +5 -5
- data/spec/ruby_speech/ssml/p_spec.rb +17 -17
- data/spec/ruby_speech/ssml/phoneme_spec.rb +8 -8
- data/spec/ruby_speech/ssml/prosody_spec.rb +82 -64
- data/spec/ruby_speech/ssml/s_spec.rb +16 -16
- data/spec/ruby_speech/ssml/say_as_spec.rb +9 -9
- data/spec/ruby_speech/ssml/speak_spec.rb +29 -29
- data/spec/ruby_speech/ssml/sub_spec.rb +7 -7
- data/spec/ruby_speech/ssml/voice_spec.rb +31 -31
- data/spec/ruby_speech/ssml_spec.rb +41 -17
- data/spec/ruby_speech_spec.rb +3 -3
- data/spec/spec_helper.rb +8 -3
- data/spec/support/dtmf_helper.rb +14 -0
- data/spec/support/grammar_matchers.rb +6 -6
- data/spec/support/match_examples.rb +5 -5
- data/spec/support/matchers.rb +1 -1
- metadata +109 -80
@@ -13,7 +13,7 @@ module RubySpeech
|
|
13
13
|
its(:repeat) { should == 1 }
|
14
14
|
|
15
15
|
it 'registers itself' do
|
16
|
-
Element.class_from_registration(:item).
|
16
|
+
expect(Element.class_from_registration(:item)).to eq(Item)
|
17
17
|
end
|
18
18
|
|
19
19
|
describe "everything from a document" do
|
@@ -21,7 +21,7 @@ module RubySpeech
|
|
21
21
|
|
22
22
|
subject { Element.import document }
|
23
23
|
|
24
|
-
it {
|
24
|
+
it { is_expected.to be_instance_of Item }
|
25
25
|
|
26
26
|
its(:weight) { should == 1.1 }
|
27
27
|
its(:repeat) { should == 1 }
|
@@ -54,16 +54,16 @@ module RubySpeech
|
|
54
54
|
its(:weight) { should == 1.1 }
|
55
55
|
|
56
56
|
it "with valid value" do
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
57
|
+
expect { subject.weight = 1 }.not_to raise_error
|
58
|
+
expect { subject.weight = 1.0 }.not_to raise_error
|
59
|
+
expect { subject.weight = 0.1 }.not_to raise_error
|
60
|
+
expect { subject.weight = '.1' }.not_to raise_error
|
61
|
+
expect { subject.weight = '1.' }.not_to raise_error
|
62
62
|
end
|
63
63
|
|
64
64
|
it "with an invalid value" do
|
65
|
-
|
66
|
-
|
65
|
+
expect { subject.weight = 'one' }.to raise_error(ArgumentError, "A Item's weight attribute must be a positive floating point number")
|
66
|
+
expect { subject.weight = -1 }.to raise_error(ArgumentError, "A Item's weight attribute must be a positive floating point number")
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
@@ -87,8 +87,8 @@ module RubySpeech
|
|
87
87
|
end
|
88
88
|
|
89
89
|
it "invalid values" do
|
90
|
-
|
91
|
-
|
90
|
+
expect { subject.repeat = -1 }.to raise_error(ArgumentError, "A Item's repeat must be 0 or a positive integer")
|
91
|
+
expect { subject.repeat = 'one' }.to raise_error(ArgumentError, "A Item's repeat must be 0 or a positive integer")
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
@@ -111,12 +111,12 @@ module RubySpeech
|
|
111
111
|
end
|
112
112
|
|
113
113
|
it "illegal ranges from m to n" do
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
114
|
+
expect { subject.repeat = '5-1' }.to raise_error(ArgumentError, "A Item's repeat must be 0 or a positive integer")
|
115
|
+
expect { subject.repeat = '-1-2' }.to raise_error(ArgumentError, "A Item's repeat must be 0 or a positive integer")
|
116
|
+
expect { subject.repeat = '1-2-3' }.to raise_error(ArgumentError, "A Item's repeat must be 0 or a positive integer")
|
117
|
+
expect { subject.repeat = '1-B' }.to raise_error(ArgumentError, "A Item's repeat must be 0 or a positive integer")
|
118
|
+
expect { subject.repeat = -1..2 }.to raise_error(ArgumentError, "A Item's repeat must be 0 or a positive integer")
|
119
|
+
expect { subject.repeat = 1..-2 }.to raise_error(ArgumentError, "A Item's repeat must be 0 or a positive integer")
|
120
120
|
end
|
121
121
|
|
122
122
|
context "valid ranges of m or more" do
|
@@ -134,8 +134,8 @@ module RubySpeech
|
|
134
134
|
end
|
135
135
|
|
136
136
|
it "illegal ranges for m or more" do
|
137
|
-
|
138
|
-
|
137
|
+
expect { subject.repeat = '-1-' }.to raise_error(ArgumentError, "A Item's repeat must be 0 or a positive integer")
|
138
|
+
expect { subject.repeat = 'B-' }.to raise_error(ArgumentError, "A Item's repeat must be 0 or a positive integer")
|
139
139
|
end
|
140
140
|
end
|
141
141
|
end
|
@@ -143,17 +143,17 @@ module RubySpeech
|
|
143
143
|
# repeat probability (repeat-prob) -- http://www.w3.org/TR/speech-grammar/#S2.5.1
|
144
144
|
describe "#repeat_prob" do
|
145
145
|
it "should handle all valid values" do
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
146
|
+
expect { subject.repeat_prob = 0 }.not_to raise_error
|
147
|
+
expect { subject.repeat_prob = 1 }.not_to raise_error
|
148
|
+
expect { subject.repeat_prob = 1.0 }.not_to raise_error
|
149
|
+
expect { subject.repeat_prob = '1.' }.not_to raise_error
|
150
|
+
expect { subject.repeat_prob = '1.0' }.not_to raise_error
|
151
|
+
expect { subject.repeat_prob = '.5' }.not_to raise_error
|
152
152
|
end
|
153
153
|
|
154
154
|
it "should raise an error for invalid values" do
|
155
|
-
|
156
|
-
|
155
|
+
expect { subject.repeat_prob = -1 }.to raise_error(ArgumentError, "A Item's repeat probablity attribute must be a floating point number between 0.0 and 1.0")
|
156
|
+
expect { subject.repeat_prob = 1.5 }.to raise_error(ArgumentError, "A Item's repeat probablity attribute must be a floating point number between 0.0 and 1.0")
|
157
157
|
end
|
158
158
|
end
|
159
159
|
|
@@ -166,27 +166,27 @@ module RubySpeech
|
|
166
166
|
|
167
167
|
describe "<<" do
|
168
168
|
it "should accept String" do
|
169
|
-
|
169
|
+
expect { subject << 'anything' }.not_to raise_error
|
170
170
|
end
|
171
171
|
|
172
172
|
it "should accept OneOf" do
|
173
|
-
|
173
|
+
expect { subject << OneOf.new(doc) }.not_to raise_error
|
174
174
|
end
|
175
175
|
|
176
176
|
it "should accept Item" do
|
177
|
-
|
177
|
+
expect { subject << Item.new(doc) }.not_to raise_error
|
178
178
|
end
|
179
179
|
|
180
180
|
it "should accept Ruleref" do
|
181
|
-
|
181
|
+
expect { subject << Ruleref.new(doc) }.not_to raise_error
|
182
182
|
end
|
183
183
|
|
184
184
|
it "should accept Tag" do
|
185
|
-
|
185
|
+
expect { subject << Tag.new(doc) }.not_to raise_error
|
186
186
|
end
|
187
187
|
|
188
188
|
it "should accept Token" do
|
189
|
-
|
189
|
+
expect { subject << Token.new(doc) }.not_to raise_error
|
190
190
|
end
|
191
191
|
end
|
192
192
|
end # Item
|
@@ -23,17 +23,17 @@ module RubySpeech
|
|
23
23
|
:confidence => 1,
|
24
24
|
:utterance => '6',
|
25
25
|
:interpretation => 'dtmf-6'
|
26
|
-
subject.match(input).
|
27
|
-
input.
|
26
|
+
expect(subject.match(input)).to eq(expected_match)
|
27
|
+
expect(input).to eq('6')
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should potentially match an empty buffer" do
|
31
|
-
subject.match('').
|
31
|
+
expect(subject.match('')).to eq(GRXML::PotentialMatch.new)
|
32
32
|
end
|
33
33
|
|
34
34
|
%w{1 2 3 4 5 7 8 9 10 66 26 61}.each do |input|
|
35
35
|
it "should not match '#{input}'" do
|
36
|
-
subject.match(input).
|
36
|
+
expect(subject.match(input)).to eq(GRXML::NoMatch.new)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
@@ -69,7 +69,7 @@ module RubySpeech
|
|
69
69
|
it "should return the literal tag interpretation" do
|
70
70
|
expected_match = GRXML::MaxMatch.new mode: :dtmf, confidence: 1,
|
71
71
|
utterance: '2', interpretation: 'bar'
|
72
|
-
subject.match('2').
|
72
|
+
expect(subject.match('2')).to eq(expected_match)
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
@@ -87,18 +87,18 @@ module RubySpeech
|
|
87
87
|
:confidence => 1,
|
88
88
|
:utterance => '56',
|
89
89
|
:interpretation => 'dtmf-5 dtmf-6'
|
90
|
-
subject.match('56').
|
90
|
+
expect(subject.match('56')).to eq(expected_match)
|
91
91
|
end
|
92
92
|
|
93
93
|
it "should potentially match '5'" do
|
94
94
|
input = '5'
|
95
|
-
subject.match(input).
|
96
|
-
input.
|
95
|
+
expect(subject.match(input)).to eq(GRXML::PotentialMatch.new)
|
96
|
+
expect(input).to eq('5')
|
97
97
|
end
|
98
98
|
|
99
99
|
%w{* *7 #6 6* 1 2 3 4 6 7 8 9 10 65 57 46 26 61}.each do |input|
|
100
100
|
it "should not match '#{input}'" do
|
101
|
-
subject.match(input).
|
101
|
+
expect(subject.match(input)).to eq(GRXML::NoMatch.new)
|
102
102
|
end
|
103
103
|
end
|
104
104
|
end
|
@@ -117,16 +117,16 @@ module RubySpeech
|
|
117
117
|
:confidence => 1,
|
118
118
|
:utterance => '*6',
|
119
119
|
:interpretation => 'dtmf-star dtmf-6'
|
120
|
-
subject.match('*6').
|
120
|
+
expect(subject.match('*6')).to eq(expected_match)
|
121
121
|
end
|
122
122
|
|
123
123
|
it "should potentially match '*'" do
|
124
|
-
subject.match('*').
|
124
|
+
expect(subject.match('*')).to eq(GRXML::PotentialMatch.new)
|
125
125
|
end
|
126
126
|
|
127
127
|
%w{*7 #6 6* 1 2 3 4 5 6 7 8 9 10 66 26 61}.each do |input|
|
128
128
|
it "should not match '#{input}'" do
|
129
|
-
subject.match(input).
|
129
|
+
expect(subject.match(input)).to eq(GRXML::NoMatch.new)
|
130
130
|
end
|
131
131
|
end
|
132
132
|
end
|
@@ -145,16 +145,16 @@ module RubySpeech
|
|
145
145
|
:confidence => 1,
|
146
146
|
:utterance => '#6',
|
147
147
|
:interpretation => 'dtmf-pound dtmf-6'
|
148
|
-
subject.match('#6').
|
148
|
+
expect(subject.match('#6')).to eq(expected_match)
|
149
149
|
end
|
150
150
|
|
151
151
|
it "should potentially match '#'" do
|
152
|
-
subject.match('#').
|
152
|
+
expect(subject.match('#')).to eq(GRXML::PotentialMatch.new)
|
153
153
|
end
|
154
154
|
|
155
155
|
%w{* *6 #7 6* 1 2 3 4 5 6 7 8 9 10 66 26 61}.each do |input|
|
156
156
|
it "should not match '#{input}'" do
|
157
|
-
subject.match(input).
|
157
|
+
expect(subject.match(input)).to eq(GRXML::NoMatch.new)
|
158
158
|
end
|
159
159
|
end
|
160
160
|
end
|
@@ -178,16 +178,16 @@ module RubySpeech
|
|
178
178
|
:confidence => 1,
|
179
179
|
:utterance => '*6',
|
180
180
|
:interpretation => 'dtmf-star dtmf-6'
|
181
|
-
subject.match('*6').
|
181
|
+
expect(subject.match('*6')).to eq(expected_match)
|
182
182
|
end
|
183
183
|
|
184
184
|
it "should potentially match '*'" do
|
185
|
-
subject.match('*').
|
185
|
+
expect(subject.match('*')).to eq(GRXML::PotentialMatch.new)
|
186
186
|
end
|
187
187
|
|
188
188
|
%w{*7 #6 6* 1 2 3 4 5 6 7 8 9 10 66 26 61}.each do |input|
|
189
189
|
it "should not match '#{input}'" do
|
190
|
-
subject.match(input).
|
190
|
+
expect(subject.match(input)).to eq(GRXML::NoMatch.new)
|
191
191
|
end
|
192
192
|
end
|
193
193
|
end
|
@@ -209,7 +209,7 @@ module RubySpeech
|
|
209
209
|
:confidence => 1,
|
210
210
|
:utterance => '6',
|
211
211
|
:interpretation => 'dtmf-6'
|
212
|
-
subject.match('6').
|
212
|
+
expect(subject.match('6')).to eq(expected_match)
|
213
213
|
end
|
214
214
|
|
215
215
|
it "should maximally match '7'" do
|
@@ -217,12 +217,12 @@ module RubySpeech
|
|
217
217
|
:confidence => 1,
|
218
218
|
:utterance => '7',
|
219
219
|
:interpretation => 'dtmf-7'
|
220
|
-
subject.match('7').
|
220
|
+
expect(subject.match('7')).to eq(expected_match)
|
221
221
|
end
|
222
222
|
|
223
223
|
%w{* # 1 2 3 4 5 8 9 10 66 26 61}.each do |input|
|
224
224
|
it "should not match '#{input}'" do
|
225
|
-
subject.match(input).
|
225
|
+
expect(subject.match(input)).to eq(GRXML::NoMatch.new)
|
226
226
|
end
|
227
227
|
end
|
228
228
|
end
|
@@ -250,7 +250,7 @@ module RubySpeech
|
|
250
250
|
:confidence => 1,
|
251
251
|
:utterance => '65',
|
252
252
|
:interpretation => 'dtmf-6 dtmf-5'
|
253
|
-
subject.match('65').
|
253
|
+
expect(subject.match('65')).to eq(expected_match)
|
254
254
|
end
|
255
255
|
|
256
256
|
it "should maximally match '72'" do
|
@@ -258,18 +258,18 @@ module RubySpeech
|
|
258
258
|
:confidence => 1,
|
259
259
|
:utterance => '72',
|
260
260
|
:interpretation => 'dtmf-7 dtmf-2'
|
261
|
-
subject.match('72').
|
261
|
+
expect(subject.match('72')).to eq(expected_match)
|
262
262
|
end
|
263
263
|
|
264
264
|
%w{6 7}.each do |input|
|
265
265
|
it "should potentially match '#{input}'" do
|
266
|
-
subject.match(input).
|
266
|
+
expect(subject.match(input)).to eq(GRXML::PotentialMatch.new)
|
267
267
|
end
|
268
268
|
end
|
269
269
|
|
270
270
|
%w{* # 1 2 3 4 5 8 9 10 66 26 61 75}.each do |input|
|
271
271
|
it "should not match '#{input}'" do
|
272
|
-
subject.match(input).
|
272
|
+
expect(subject.match(input)).to eq(GRXML::NoMatch.new)
|
273
273
|
end
|
274
274
|
end
|
275
275
|
end
|
@@ -299,7 +299,7 @@ module RubySpeech
|
|
299
299
|
:confidence => 1,
|
300
300
|
:utterance => '652',
|
301
301
|
:interpretation => 'dtmf-6 dtmf-5 dtmf-2'
|
302
|
-
subject.match('652').
|
302
|
+
expect(subject.match('652')).to eq(expected_match)
|
303
303
|
end
|
304
304
|
|
305
305
|
it "should maximally match '728'" do
|
@@ -307,18 +307,18 @@ module RubySpeech
|
|
307
307
|
:confidence => 1,
|
308
308
|
:utterance => '728',
|
309
309
|
:interpretation => 'dtmf-7 dtmf-2 dtmf-8'
|
310
|
-
subject.match('728').
|
310
|
+
expect(subject.match('728')).to eq(expected_match)
|
311
311
|
end
|
312
312
|
|
313
313
|
%w{6 65 7 72}.each do |input|
|
314
314
|
it "should potentially match '#{input}'" do
|
315
|
-
subject.match(input).
|
315
|
+
expect(subject.match(input)).to eq(GRXML::PotentialMatch.new)
|
316
316
|
end
|
317
317
|
end
|
318
318
|
|
319
319
|
%w{* # 1 2 3 4 5 8 9 10 66 26 61 75 729 654}.each do |input|
|
320
320
|
it "should not match '#{input}'" do
|
321
|
-
subject.match(input).
|
321
|
+
expect(subject.match(input)).to eq(GRXML::NoMatch.new)
|
322
322
|
end
|
323
323
|
end
|
324
324
|
end
|
@@ -341,7 +341,7 @@ module RubySpeech
|
|
341
341
|
:confidence => 1,
|
342
342
|
:utterance => '*6',
|
343
343
|
:interpretation => 'dtmf-star dtmf-6'
|
344
|
-
subject.match('*6').
|
344
|
+
expect(subject.match('*6')).to eq(expected_match)
|
345
345
|
end
|
346
346
|
|
347
347
|
it "should maximally match '*7'" do
|
@@ -349,16 +349,16 @@ module RubySpeech
|
|
349
349
|
:confidence => 1,
|
350
350
|
:utterance => '*7',
|
351
351
|
:interpretation => 'dtmf-star dtmf-7'
|
352
|
-
subject.match('*7').
|
352
|
+
expect(subject.match('*7')).to eq(expected_match)
|
353
353
|
end
|
354
354
|
|
355
355
|
it "should potentially match '*'" do
|
356
|
-
subject.match('*').
|
356
|
+
expect(subject.match('*')).to eq(GRXML::PotentialMatch.new)
|
357
357
|
end
|
358
358
|
|
359
359
|
%w{*8 #6 6* 1 2 3 4 5 6 7 8 9 10 66 26 61}.each do |input|
|
360
360
|
it "should not match '#{input}'" do
|
361
|
-
subject.match(input).
|
361
|
+
expect(subject.match(input)).to eq(GRXML::NoMatch.new)
|
362
362
|
end
|
363
363
|
end
|
364
364
|
end
|
@@ -381,7 +381,7 @@ module RubySpeech
|
|
381
381
|
:confidence => 1,
|
382
382
|
:utterance => '6*',
|
383
383
|
:interpretation => 'dtmf-6 dtmf-star'
|
384
|
-
subject.match('6*').
|
384
|
+
expect(subject.match('6*')).to eq(expected_match)
|
385
385
|
end
|
386
386
|
|
387
387
|
it "should maximally match '7*'" do
|
@@ -389,22 +389,22 @@ module RubySpeech
|
|
389
389
|
:confidence => 1,
|
390
390
|
:utterance => '7*',
|
391
391
|
:interpretation => 'dtmf-7 dtmf-star'
|
392
|
-
subject.match('7*').
|
392
|
+
expect(subject.match('7*')).to eq(expected_match)
|
393
393
|
end
|
394
394
|
|
395
395
|
%w{6 7}.each do |input|
|
396
396
|
it "should potentially match '#{input}'" do
|
397
|
-
subject.match(input).
|
397
|
+
expect(subject.match(input)).to eq(GRXML::PotentialMatch.new)
|
398
398
|
end
|
399
399
|
end
|
400
400
|
|
401
401
|
it "should potentially match '7'" do
|
402
|
-
subject.match('7').
|
402
|
+
expect(subject.match('7')).to eq(GRXML::PotentialMatch.new)
|
403
403
|
end
|
404
404
|
|
405
405
|
%w{8* 6# *6 *7 1 2 3 4 5 8 9 10 66 26 61}.each do |input|
|
406
406
|
it "should not match '#{input}'" do
|
407
|
-
subject.match(input).
|
407
|
+
expect(subject.match(input)).to eq(GRXML::NoMatch.new)
|
408
408
|
end
|
409
409
|
end
|
410
410
|
end
|
@@ -426,18 +426,18 @@ module RubySpeech
|
|
426
426
|
:confidence => 1,
|
427
427
|
:utterance => '166',
|
428
428
|
:interpretation => 'dtmf-1 dtmf-6 dtmf-6'
|
429
|
-
subject.match('166').
|
429
|
+
expect(subject.match('166')).to eq(expected_match)
|
430
430
|
end
|
431
431
|
|
432
432
|
%w{1 16}.each do |input|
|
433
433
|
it "should potentially match '#{input}'" do
|
434
|
-
subject.match(input).
|
434
|
+
expect(subject.match(input)).to eq(GRXML::PotentialMatch.new)
|
435
435
|
end
|
436
436
|
end
|
437
437
|
|
438
438
|
%w{1666 16666 17}.each do |input|
|
439
439
|
it "should not match '#{input}'" do
|
440
|
-
subject.match(input).
|
440
|
+
expect(subject.match(input)).to eq(GRXML::NoMatch.new)
|
441
441
|
end
|
442
442
|
end
|
443
443
|
end
|
@@ -459,18 +459,18 @@ module RubySpeech
|
|
459
459
|
:confidence => 1,
|
460
460
|
:utterance => '661',
|
461
461
|
:interpretation => 'dtmf-6 dtmf-6 dtmf-1'
|
462
|
-
subject.match('661').
|
462
|
+
expect(subject.match('661')).to eq(expected_match)
|
463
463
|
end
|
464
464
|
|
465
465
|
%w{6 66}.each do |input|
|
466
466
|
it "should potentially match '#{input}'" do
|
467
|
-
subject.match(input).
|
467
|
+
expect(subject.match(input)).to eq(GRXML::PotentialMatch.new)
|
468
468
|
end
|
469
469
|
end
|
470
470
|
|
471
471
|
%w{61 6661 66661 71 771}.each do |input|
|
472
472
|
it "should not match '#{input}'" do
|
473
|
-
subject.match(input).
|
473
|
+
expect(subject.match(input)).to eq(GRXML::NoMatch.new)
|
474
474
|
end
|
475
475
|
end
|
476
476
|
end
|
@@ -492,7 +492,7 @@ module RubySpeech
|
|
492
492
|
:confidence => 1,
|
493
493
|
:utterance => '1666',
|
494
494
|
:interpretation => 'dtmf-1 dtmf-6 dtmf-6 dtmf-6'
|
495
|
-
subject.match('1666').
|
495
|
+
expect(subject.match('1666')).to eq(expected_match)
|
496
496
|
end
|
497
497
|
|
498
498
|
{
|
@@ -505,13 +505,57 @@ module RubySpeech
|
|
505
505
|
:confidence => 1,
|
506
506
|
:utterance => input,
|
507
507
|
:interpretation => interpretation
|
508
|
-
subject.match(input).
|
508
|
+
expect(subject.match(input)).to eq(expected_match)
|
509
509
|
end
|
510
510
|
end
|
511
511
|
|
512
512
|
%w{6 16666 17}.each do |input|
|
513
513
|
it "should not match '#{input}'" do
|
514
|
-
subject.match(input).
|
514
|
+
expect(subject.match(input)).to eq(GRXML::NoMatch.new)
|
515
|
+
end
|
516
|
+
end
|
517
|
+
end
|
518
|
+
|
519
|
+
context "with a grammar that takes a a specific digit repeated within a range" do
|
520
|
+
let(:grammar) do
|
521
|
+
GRXML.draw :mode => :dtmf, :root => 'digits' do
|
522
|
+
rule :id => 'digits' do
|
523
|
+
item :repeat => 0..3 do
|
524
|
+
'6'
|
525
|
+
end
|
526
|
+
end
|
527
|
+
end
|
528
|
+
end
|
529
|
+
|
530
|
+
{
|
531
|
+
'' => '',
|
532
|
+
'6' => 'dtmf-6',
|
533
|
+
'66' => 'dtmf-6 dtmf-6',
|
534
|
+
}.each_pair do |input, interpretation|
|
535
|
+
it "should match '#{input}'" do
|
536
|
+
expected_match = GRXML::Match.new :mode => :dtmf,
|
537
|
+
:confidence => 1,
|
538
|
+
:utterance => input,
|
539
|
+
:interpretation => interpretation
|
540
|
+
expect(subject.match(input)).to eq(expected_match)
|
541
|
+
end
|
542
|
+
end
|
543
|
+
|
544
|
+
{
|
545
|
+
'666' => 'dtmf-6 dtmf-6 dtmf-6',
|
546
|
+
}.each_pair do |input, interpretation|
|
547
|
+
it "should maximally match '#{input}'" do
|
548
|
+
expected_match = GRXML::MaxMatch.new :mode => :dtmf,
|
549
|
+
:confidence => 1,
|
550
|
+
:utterance => input,
|
551
|
+
:interpretation => interpretation
|
552
|
+
expect(subject.match(input)).to eq(expected_match)
|
553
|
+
end
|
554
|
+
end
|
555
|
+
|
556
|
+
%w{6666 7}.each do |input|
|
557
|
+
it "should not match '#{input}'" do
|
558
|
+
expect(subject.match(input)).to eq(GRXML::NoMatch.new)
|
515
559
|
end
|
516
560
|
end
|
517
561
|
end
|
@@ -539,19 +583,19 @@ module RubySpeech
|
|
539
583
|
:confidence => 1,
|
540
584
|
:utterance => input,
|
541
585
|
:interpretation => interpretation
|
542
|
-
subject.match(input).
|
586
|
+
expect(subject.match(input)).to eq(expected_match)
|
543
587
|
end
|
544
588
|
end
|
545
589
|
|
546
590
|
%w{6 66 666}.each do |input|
|
547
591
|
it "should potentially match '#{input}'" do
|
548
|
-
subject.match(input).
|
592
|
+
expect(subject.match(input)).to eq(GRXML::PotentialMatch.new)
|
549
593
|
end
|
550
594
|
end
|
551
595
|
|
552
596
|
%w{66661 71}.each do |input|
|
553
597
|
it "should not match '#{input}'" do
|
554
|
-
subject.match(input).
|
598
|
+
expect(subject.match(input)).to eq(GRXML::NoMatch.new)
|
555
599
|
end
|
556
600
|
end
|
557
601
|
end
|
@@ -578,19 +622,19 @@ module RubySpeech
|
|
578
622
|
:confidence => 1,
|
579
623
|
:utterance => input,
|
580
624
|
:interpretation => interpretation
|
581
|
-
subject.match(input).
|
625
|
+
expect(subject.match(input)).to eq(expected_match)
|
582
626
|
end
|
583
627
|
end
|
584
628
|
|
585
629
|
%w{1 16}.each do |input|
|
586
630
|
it "should potentially match '#{input}'" do
|
587
|
-
subject.match(input).
|
631
|
+
expect(subject.match(input)).to eq(GRXML::PotentialMatch.new)
|
588
632
|
end
|
589
633
|
end
|
590
634
|
|
591
635
|
%w{7 17}.each do |input|
|
592
636
|
it "should not match '#{input}'" do
|
593
|
-
subject.match(input).
|
637
|
+
expect(subject.match(input)).to eq(GRXML::NoMatch.new)
|
594
638
|
end
|
595
639
|
end
|
596
640
|
end
|
@@ -617,19 +661,19 @@ module RubySpeech
|
|
617
661
|
:confidence => 1,
|
618
662
|
:utterance => input,
|
619
663
|
:interpretation => interpretation
|
620
|
-
subject.match(input).
|
664
|
+
expect(subject.match(input)).to eq(expected_match)
|
621
665
|
end
|
622
666
|
end
|
623
667
|
|
624
668
|
%w{6 66}.each do |input|
|
625
669
|
it "should potentially match '#{input}'" do
|
626
|
-
subject.match(input).
|
670
|
+
expect(subject.match(input)).to eq(GRXML::PotentialMatch.new)
|
627
671
|
end
|
628
672
|
end
|
629
673
|
|
630
674
|
%w{7 71 61}.each do |input|
|
631
675
|
it "should not match '#{input}'" do
|
632
|
-
subject.match(input).
|
676
|
+
expect(subject.match(input)).to eq(GRXML::NoMatch.new)
|
633
677
|
end
|
634
678
|
end
|
635
679
|
end
|
@@ -670,19 +714,19 @@ module RubySpeech
|
|
670
714
|
:confidence => 1,
|
671
715
|
:utterance => input,
|
672
716
|
:interpretation => interpretation
|
673
|
-
subject.match(input).
|
717
|
+
expect(subject.match(input)).to eq(expected_match)
|
674
718
|
end
|
675
719
|
end
|
676
720
|
|
677
721
|
%w{* 1 12 123 1234}.each do |input|
|
678
722
|
it "should potentially match '#{input}'" do
|
679
|
-
subject.match(input).
|
723
|
+
expect(subject.match(input)).to eq(GRXML::PotentialMatch.new)
|
680
724
|
end
|
681
725
|
end
|
682
726
|
|
683
727
|
%w{11111 #1111 *7}.each do |input|
|
684
728
|
it "should not match '#{input}'" do
|
685
|
-
subject.match(input).
|
729
|
+
expect(subject.match(input)).to eq(GRXML::NoMatch.new)
|
686
730
|
end
|
687
731
|
end
|
688
732
|
end
|
@@ -5,11 +5,11 @@ module RubySpeech
|
|
5
5
|
describe MaxMatch do
|
6
6
|
it_behaves_like "match"
|
7
7
|
|
8
|
-
it {
|
8
|
+
it { is_expected.to be_a Match }
|
9
9
|
|
10
10
|
describe "equality" do
|
11
11
|
it "should never be equal to a MaxMatch" do
|
12
|
-
described_class.new.
|
12
|
+
expect(described_class.new).not_to eql(Match.new)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -5,11 +5,11 @@ module RubySpeech
|
|
5
5
|
describe NoMatch do
|
6
6
|
describe "equality" do
|
7
7
|
it "should be equal to another NoMatch" do
|
8
|
-
NoMatch.new.
|
8
|
+
expect(NoMatch.new).to eq(NoMatch.new)
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should not equal a match" do
|
12
|
-
NoMatch.new.
|
12
|
+
expect(NoMatch.new).not_to eq(Match.new)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|