ruby_speech 1.1.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -1
- data/.travis.yml +5 -1
- data/CHANGELOG.md +20 -5
- data/Gemfile +1 -1
- data/Guardfile +4 -0
- data/README.md +47 -101
- data/Rakefile +14 -2
- data/ext/ruby_speech/RubySpeechGRXMLMatcher.java +42 -0
- data/ext/ruby_speech/RubySpeechService.java +23 -0
- data/ext/ruby_speech/extconf.rb +7 -0
- data/ext/ruby_speech/ruby_speech.c +41 -0
- data/lib/ruby_speech/grxml.rb +1 -0
- data/lib/ruby_speech/grxml/element.rb +0 -17
- data/lib/ruby_speech/grxml/grammar.rb +0 -103
- data/lib/ruby_speech/grxml/item.rb +0 -21
- data/lib/ruby_speech/grxml/matcher.rb +129 -0
- data/lib/ruby_speech/grxml/one_of.rb +0 -4
- data/lib/ruby_speech/grxml/token.rb +0 -4
- data/lib/ruby_speech/nlsml.rb +1 -2
- data/lib/ruby_speech/nlsml/builder.rb +2 -15
- data/lib/ruby_speech/nlsml/document.rb +13 -9
- data/lib/ruby_speech/version.rb +1 -1
- data/ruby_speech.gemspec +10 -3
- data/spec/ruby_speech/grxml/grammar_spec.rb +0 -528
- data/spec/ruby_speech/grxml/item_spec.rb +0 -385
- data/spec/ruby_speech/grxml/matcher_spec.rb +644 -0
- data/spec/ruby_speech/grxml/one_of_spec.rb +0 -238
- data/spec/ruby_speech/nlsml_spec.rb +106 -148
- data/spec/ruby_speech_spec.rb +11 -21
- data/spec/spec_helper.rb +0 -1
- metadata +52 -78
data/lib/ruby_speech/version.rb
CHANGED
data/ruby_speech.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.authors = ["Ben Langfeld"]
|
9
9
|
s.email = ["ben@langfeld.me"]
|
10
10
|
s.homepage = "https://github.com/benlangfeld/ruby_speech"
|
11
|
-
s.summary = %q{A
|
11
|
+
s.summary = %q{A Ruby library for TTS & ASR document preparation}
|
12
12
|
s.description = %q{Prepare SSML and GRXML documents with ease}
|
13
13
|
|
14
14
|
s.rubyforge_project = "ruby_speech"
|
@@ -18,6 +18,13 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
|
+
if RUBY_PLATFORM =~ /java/
|
22
|
+
s.platform = "java"
|
23
|
+
s.files << "lib/ruby_speech/ruby_speech.jar"
|
24
|
+
else
|
25
|
+
s.extensions = ['ext/ruby_speech/extconf.rb']
|
26
|
+
end
|
27
|
+
|
21
28
|
s.add_runtime_dependency %q<niceogiri>, ["~> 1.1", ">= 1.1.1"]
|
22
29
|
s.add_runtime_dependency %q<nokogiri>, ["~> 1.5", ">= 1.5.6"]
|
23
30
|
s.add_runtime_dependency %q<activesupport>, [">= 3.0.7"]
|
@@ -27,9 +34,9 @@ Gem::Specification.new do |s|
|
|
27
34
|
s.add_development_dependency %q<ci_reporter>, [">= 1.6.3"]
|
28
35
|
s.add_development_dependency %q<yard>, [">= 0.7.0"]
|
29
36
|
s.add_development_dependency %q<rake>, [">= 0"]
|
30
|
-
s.add_development_dependency %q<mocha>, [">= 0"]
|
31
|
-
s.add_development_dependency %q<i18n>, [">= 0"]
|
32
37
|
s.add_development_dependency %q<guard>, [">= 0.9.0"]
|
33
38
|
s.add_development_dependency %q<guard-rspec>, [">= 0"]
|
34
39
|
s.add_development_dependency %q<ruby_gntp>, [">= 0"]
|
40
|
+
s.add_development_dependency %q<guard-rake>, [">= 0"]
|
41
|
+
s.add_development_dependency %q<rake-compiler>, [">= 0"]
|
35
42
|
end
|
@@ -336,534 +336,6 @@ module RubySpeech
|
|
336
336
|
grammar.should == normalized_grammar
|
337
337
|
end
|
338
338
|
end
|
339
|
-
|
340
|
-
describe "matching against an input string" do
|
341
|
-
before do
|
342
|
-
subject.inline!
|
343
|
-
subject.tokenize!
|
344
|
-
subject.normalize_whitespace
|
345
|
-
end
|
346
|
-
|
347
|
-
context "with a grammar that takes a single specific digit" do
|
348
|
-
subject do
|
349
|
-
GRXML.draw :mode => :dtmf, :root => 'digit' do
|
350
|
-
rule :id => 'digit' do
|
351
|
-
'6'
|
352
|
-
end
|
353
|
-
end
|
354
|
-
end
|
355
|
-
|
356
|
-
it "should match '6'" do
|
357
|
-
input = '6'
|
358
|
-
expected_match = GRXML::Match.new :mode => :dtmf,
|
359
|
-
:confidence => 1,
|
360
|
-
:utterance => '6',
|
361
|
-
:interpretation => 'dtmf-6'
|
362
|
-
subject.match(input).should == expected_match
|
363
|
-
input.should == '6'
|
364
|
-
end
|
365
|
-
|
366
|
-
%w{1 2 3 4 5 7 8 9 10 66 26 61}.each do |input|
|
367
|
-
it "should not match '#{input}'" do
|
368
|
-
subject.match(input).should == GRXML::NoMatch.new
|
369
|
-
end
|
370
|
-
end
|
371
|
-
end
|
372
|
-
|
373
|
-
context "with a grammar that takes two specific digits" do
|
374
|
-
subject do
|
375
|
-
GRXML.draw :mode => :dtmf, :root => 'digits' do
|
376
|
-
rule :id => 'digits' do
|
377
|
-
'5 6'
|
378
|
-
end
|
379
|
-
end
|
380
|
-
end
|
381
|
-
|
382
|
-
it "should match '56'" do
|
383
|
-
expected_match = GRXML::Match.new :mode => :dtmf,
|
384
|
-
:confidence => 1,
|
385
|
-
:utterance => '56',
|
386
|
-
:interpretation => 'dtmf-5 dtmf-6'
|
387
|
-
subject.match('56').should == expected_match
|
388
|
-
end
|
389
|
-
|
390
|
-
it "should potentially match '5'" do
|
391
|
-
input = '5'
|
392
|
-
subject.match(input).should == GRXML::PotentialMatch.new
|
393
|
-
input.should == '5'
|
394
|
-
end
|
395
|
-
|
396
|
-
%w{* *7 #6 6* 1 2 3 4 6 7 8 9 10 65 57 46 26 61}.each do |input|
|
397
|
-
it "should not match '#{input}'" do
|
398
|
-
subject.match(input).should == GRXML::NoMatch.new
|
399
|
-
end
|
400
|
-
end
|
401
|
-
end
|
402
|
-
|
403
|
-
context "with a grammar that takes star and a digit" do
|
404
|
-
subject do
|
405
|
-
GRXML.draw :mode => :dtmf, :root => 'digits' do
|
406
|
-
rule :id => 'digits' do
|
407
|
-
'* 6'
|
408
|
-
end
|
409
|
-
end
|
410
|
-
end
|
411
|
-
|
412
|
-
it "should match '*6'" do
|
413
|
-
expected_match = GRXML::Match.new :mode => :dtmf,
|
414
|
-
:confidence => 1,
|
415
|
-
:utterance => '*6',
|
416
|
-
:interpretation => 'dtmf-star dtmf-6'
|
417
|
-
subject.match('*6').should == expected_match
|
418
|
-
end
|
419
|
-
|
420
|
-
it "should potentially match '*'" do
|
421
|
-
subject.match('*').should == GRXML::PotentialMatch.new
|
422
|
-
end
|
423
|
-
|
424
|
-
%w{*7 #6 6* 1 2 3 4 5 6 7 8 9 10 66 26 61}.each do |input|
|
425
|
-
it "should not match '#{input}'" do
|
426
|
-
subject.match(input).should == GRXML::NoMatch.new
|
427
|
-
end
|
428
|
-
end
|
429
|
-
end
|
430
|
-
|
431
|
-
context "with a grammar that takes hash and a digit" do
|
432
|
-
subject do
|
433
|
-
GRXML.draw :mode => :dtmf, :root => 'digits' do
|
434
|
-
rule :id => 'digits' do
|
435
|
-
'# 6'
|
436
|
-
end
|
437
|
-
end
|
438
|
-
end
|
439
|
-
|
440
|
-
it "should match '#6'" do
|
441
|
-
expected_match = GRXML::Match.new :mode => :dtmf,
|
442
|
-
:confidence => 1,
|
443
|
-
:utterance => '#6',
|
444
|
-
:interpretation => 'dtmf-pound dtmf-6'
|
445
|
-
subject.match('#6').should == expected_match
|
446
|
-
end
|
447
|
-
|
448
|
-
it "should potentially match '#'" do
|
449
|
-
subject.match('#').should == GRXML::PotentialMatch.new
|
450
|
-
end
|
451
|
-
|
452
|
-
%w{* *6 #7 6* 1 2 3 4 5 6 7 8 9 10 66 26 61}.each do |input|
|
453
|
-
it "should not match '#{input}'" do
|
454
|
-
subject.match(input).should == GRXML::NoMatch.new
|
455
|
-
end
|
456
|
-
end
|
457
|
-
end
|
458
|
-
|
459
|
-
context "with a grammar that takes two specific digits, via a ruleref, and whitespace normalization" do
|
460
|
-
subject do
|
461
|
-
GRXML.draw :mode => :dtmf, :root => 'digits' do
|
462
|
-
rule :id => 'digits' do
|
463
|
-
ruleref :uri => '#star'
|
464
|
-
'" 6 "'
|
465
|
-
end
|
466
|
-
|
467
|
-
rule :id => 'star' do
|
468
|
-
'" * "'
|
469
|
-
end
|
470
|
-
end
|
471
|
-
end
|
472
|
-
|
473
|
-
it "should match '*6'" do
|
474
|
-
expected_match = GRXML::Match.new :mode => :dtmf,
|
475
|
-
:confidence => 1,
|
476
|
-
:utterance => '*6',
|
477
|
-
:interpretation => 'dtmf-star dtmf-6'
|
478
|
-
subject.match('*6').should == expected_match
|
479
|
-
end
|
480
|
-
|
481
|
-
it "should potentially match '*'" do
|
482
|
-
subject.match('*').should == GRXML::PotentialMatch.new
|
483
|
-
end
|
484
|
-
|
485
|
-
%w{*7 #6 6* 1 2 3 4 5 6 7 8 9 10 66 26 61}.each do |input|
|
486
|
-
it "should not match '#{input}'" do
|
487
|
-
subject.match(input).should == GRXML::NoMatch.new
|
488
|
-
end
|
489
|
-
end
|
490
|
-
end
|
491
|
-
|
492
|
-
context "with a grammar that takes a single digit alternative" do
|
493
|
-
subject do
|
494
|
-
GRXML.draw :mode => :dtmf, :root => 'digits' do
|
495
|
-
rule :id => 'digits' do
|
496
|
-
one_of do
|
497
|
-
item { '6' }
|
498
|
-
item { '7' }
|
499
|
-
end
|
500
|
-
end
|
501
|
-
end
|
502
|
-
end
|
503
|
-
|
504
|
-
it "should match '6'" do
|
505
|
-
expected_match = GRXML::Match.new :mode => :dtmf,
|
506
|
-
:confidence => 1,
|
507
|
-
:utterance => '6',
|
508
|
-
:interpretation => 'dtmf-6'
|
509
|
-
subject.match('6').should == expected_match
|
510
|
-
end
|
511
|
-
|
512
|
-
it "should match '7'" do
|
513
|
-
expected_match = GRXML::Match.new :mode => :dtmf,
|
514
|
-
:confidence => 1,
|
515
|
-
:utterance => '7',
|
516
|
-
:interpretation => 'dtmf-7'
|
517
|
-
subject.match('7').should == expected_match
|
518
|
-
end
|
519
|
-
|
520
|
-
%w{* # 1 2 3 4 5 8 9 10 66 26 61}.each do |input|
|
521
|
-
it "should not match '#{input}'" do
|
522
|
-
subject.match(input).should == GRXML::NoMatch.new
|
523
|
-
end
|
524
|
-
end
|
525
|
-
end
|
526
|
-
|
527
|
-
context "with a grammar that takes a double digit alternative" do
|
528
|
-
subject do
|
529
|
-
GRXML.draw :mode => :dtmf, :root => 'digits' do
|
530
|
-
rule :id => 'digits' do
|
531
|
-
one_of do
|
532
|
-
item do
|
533
|
-
token { '6' }
|
534
|
-
token { '5' }
|
535
|
-
end
|
536
|
-
item do
|
537
|
-
token { '7' }
|
538
|
-
token { '2' }
|
539
|
-
end
|
540
|
-
end
|
541
|
-
end
|
542
|
-
end
|
543
|
-
end
|
544
|
-
|
545
|
-
it "should match '65'" do
|
546
|
-
expected_match = GRXML::Match.new :mode => :dtmf,
|
547
|
-
:confidence => 1,
|
548
|
-
:utterance => '65',
|
549
|
-
:interpretation => 'dtmf-6 dtmf-5'
|
550
|
-
subject.match('65').should == expected_match
|
551
|
-
end
|
552
|
-
|
553
|
-
it "should match '72'" do
|
554
|
-
expected_match = GRXML::Match.new :mode => :dtmf,
|
555
|
-
:confidence => 1,
|
556
|
-
:utterance => '72',
|
557
|
-
:interpretation => 'dtmf-7 dtmf-2'
|
558
|
-
subject.match('72').should == expected_match
|
559
|
-
end
|
560
|
-
|
561
|
-
%w{6 7}.each do |input|
|
562
|
-
it "should potentially match '#{input}'" do
|
563
|
-
subject.match(input).should == GRXML::PotentialMatch.new
|
564
|
-
end
|
565
|
-
end
|
566
|
-
|
567
|
-
%w{* # 1 2 3 4 5 8 9 10 66 26 61 75}.each do |input|
|
568
|
-
it "should not match '#{input}'" do
|
569
|
-
subject.match(input).should == GRXML::NoMatch.new
|
570
|
-
end
|
571
|
-
end
|
572
|
-
end
|
573
|
-
|
574
|
-
context "with a grammar that takes a triple digit alternative" do
|
575
|
-
subject do
|
576
|
-
GRXML.draw :mode => :dtmf, :root => 'digits' do
|
577
|
-
rule :id => 'digits' do
|
578
|
-
one_of do
|
579
|
-
item do
|
580
|
-
token { '6' }
|
581
|
-
token { '5' }
|
582
|
-
token { '2' }
|
583
|
-
end
|
584
|
-
item do
|
585
|
-
token { '7' }
|
586
|
-
token { '2' }
|
587
|
-
token { '8' }
|
588
|
-
end
|
589
|
-
end
|
590
|
-
end
|
591
|
-
end
|
592
|
-
end
|
593
|
-
|
594
|
-
it "should match '652'" do
|
595
|
-
expected_match = GRXML::Match.new :mode => :dtmf,
|
596
|
-
:confidence => 1,
|
597
|
-
:utterance => '652',
|
598
|
-
:interpretation => 'dtmf-6 dtmf-5 dtmf-2'
|
599
|
-
subject.match('652').should == expected_match
|
600
|
-
end
|
601
|
-
|
602
|
-
it "should match '728'" do
|
603
|
-
expected_match = GRXML::Match.new :mode => :dtmf,
|
604
|
-
:confidence => 1,
|
605
|
-
:utterance => '728',
|
606
|
-
:interpretation => 'dtmf-7 dtmf-2 dtmf-8'
|
607
|
-
subject.match('728').should == expected_match
|
608
|
-
end
|
609
|
-
|
610
|
-
%w{6 65 7 72}.each do |input|
|
611
|
-
it "should potentially match '#{input}'" do
|
612
|
-
subject.match(input).should == GRXML::PotentialMatch.new
|
613
|
-
end
|
614
|
-
end
|
615
|
-
|
616
|
-
%w{* # 1 2 3 4 5 8 9 10 66 26 61 75 729 654}.each do |input|
|
617
|
-
it "should not match '#{input}'" do
|
618
|
-
subject.match(input).should == GRXML::NoMatch.new
|
619
|
-
end
|
620
|
-
end
|
621
|
-
end
|
622
|
-
|
623
|
-
context "with a grammar that takes two specific digits with the second being an alternative" do
|
624
|
-
subject do
|
625
|
-
GRXML.draw :mode => :dtmf, :root => 'digits' do
|
626
|
-
rule :id => 'digits' do
|
627
|
-
string '*'
|
628
|
-
one_of do
|
629
|
-
item { '6' }
|
630
|
-
item { '7' }
|
631
|
-
end
|
632
|
-
end
|
633
|
-
end
|
634
|
-
end
|
635
|
-
|
636
|
-
it "should match '*6'" do
|
637
|
-
expected_match = GRXML::Match.new :mode => :dtmf,
|
638
|
-
:confidence => 1,
|
639
|
-
:utterance => '*6',
|
640
|
-
:interpretation => 'dtmf-star dtmf-6'
|
641
|
-
subject.match('*6').should == expected_match
|
642
|
-
end
|
643
|
-
|
644
|
-
it "should match '*7'" do
|
645
|
-
expected_match = GRXML::Match.new :mode => :dtmf,
|
646
|
-
:confidence => 1,
|
647
|
-
:utterance => '*7',
|
648
|
-
:interpretation => 'dtmf-star dtmf-7'
|
649
|
-
subject.match('*7').should == expected_match
|
650
|
-
end
|
651
|
-
|
652
|
-
it "should potentially match '*'" do
|
653
|
-
subject.match('*').should == GRXML::PotentialMatch.new
|
654
|
-
end
|
655
|
-
|
656
|
-
%w{*8 #6 6* 1 2 3 4 5 6 7 8 9 10 66 26 61}.each do |input|
|
657
|
-
it "should not match '#{input}'" do
|
658
|
-
subject.match(input).should == GRXML::NoMatch.new
|
659
|
-
end
|
660
|
-
end
|
661
|
-
end
|
662
|
-
|
663
|
-
context "with a grammar that takes two specific digits with the first being an alternative" do
|
664
|
-
subject do
|
665
|
-
GRXML.draw :mode => :dtmf, :root => 'digits' do
|
666
|
-
rule :id => 'digits' do
|
667
|
-
one_of do
|
668
|
-
item { '6' }
|
669
|
-
item { '7' }
|
670
|
-
end
|
671
|
-
string '*'
|
672
|
-
end
|
673
|
-
end
|
674
|
-
end
|
675
|
-
|
676
|
-
it "should match '6*'" do
|
677
|
-
expected_match = GRXML::Match.new :mode => :dtmf,
|
678
|
-
:confidence => 1,
|
679
|
-
:utterance => '6*',
|
680
|
-
:interpretation => 'dtmf-6 dtmf-star'
|
681
|
-
subject.match('6*').should == expected_match
|
682
|
-
end
|
683
|
-
|
684
|
-
it "should match '7*'" do
|
685
|
-
expected_match = GRXML::Match.new :mode => :dtmf,
|
686
|
-
:confidence => 1,
|
687
|
-
:utterance => '7*',
|
688
|
-
:interpretation => 'dtmf-7 dtmf-star'
|
689
|
-
subject.match('7*').should == expected_match
|
690
|
-
end
|
691
|
-
|
692
|
-
it "should potentially match '6'" do
|
693
|
-
subject.match('6').should == GRXML::PotentialMatch.new
|
694
|
-
end
|
695
|
-
|
696
|
-
it "should potentially match '7'" do
|
697
|
-
subject.match('7').should == GRXML::PotentialMatch.new
|
698
|
-
end
|
699
|
-
|
700
|
-
%w{8* 6# *6 *7 1 2 3 4 5 8 9 10 66 26 61}.each do |input|
|
701
|
-
it "should not match '#{input}'" do
|
702
|
-
subject.match(input).should == GRXML::NoMatch.new
|
703
|
-
end
|
704
|
-
end
|
705
|
-
end
|
706
|
-
|
707
|
-
context "with a grammar that takes a specific digit, followed by a specific digit repeated an exact number of times" do
|
708
|
-
subject do
|
709
|
-
GRXML.draw :mode => :dtmf, :root => 'digits' do
|
710
|
-
rule :id => 'digits' do
|
711
|
-
string '1'
|
712
|
-
item :repeat => 2 do
|
713
|
-
'6'
|
714
|
-
end
|
715
|
-
end
|
716
|
-
end
|
717
|
-
end
|
718
|
-
|
719
|
-
it "should match '166'" do
|
720
|
-
expected_match = GRXML::Match.new :mode => :dtmf,
|
721
|
-
:confidence => 1,
|
722
|
-
:utterance => '166',
|
723
|
-
:interpretation => 'dtmf-1 dtmf-6 dtmf-6'
|
724
|
-
subject.match('166').should == expected_match
|
725
|
-
end
|
726
|
-
|
727
|
-
%w{1 16}.each do |input|
|
728
|
-
it "should potentially match '#{input}'" do
|
729
|
-
subject.match(input).should == GRXML::PotentialMatch.new
|
730
|
-
end
|
731
|
-
end
|
732
|
-
|
733
|
-
%w{1666 16666 17}.each do |input|
|
734
|
-
it "should not match '#{input}'" do
|
735
|
-
subject.match(input).should == GRXML::NoMatch.new
|
736
|
-
end
|
737
|
-
end
|
738
|
-
end
|
739
|
-
|
740
|
-
context "with a grammar that takes a specific digit, followed by a specific digit repeated within a range" do
|
741
|
-
subject do
|
742
|
-
GRXML.draw :mode => :dtmf, :root => 'digits' do
|
743
|
-
rule :id => 'digits' do
|
744
|
-
string '1'
|
745
|
-
item :repeat => 0..3 do
|
746
|
-
'6'
|
747
|
-
end
|
748
|
-
end
|
749
|
-
end
|
750
|
-
end
|
751
|
-
|
752
|
-
{
|
753
|
-
'1' => 'dtmf-1',
|
754
|
-
'16' => 'dtmf-1 dtmf-6',
|
755
|
-
'166' => 'dtmf-1 dtmf-6 dtmf-6',
|
756
|
-
'1666' => 'dtmf-1 dtmf-6 dtmf-6 dtmf-6'
|
757
|
-
}.each_pair do |input, interpretation|
|
758
|
-
it "should match '#{input}'" do
|
759
|
-
expected_match = GRXML::Match.new :mode => :dtmf,
|
760
|
-
:confidence => 1,
|
761
|
-
:utterance => input,
|
762
|
-
:interpretation => interpretation
|
763
|
-
subject.match(input).should == expected_match
|
764
|
-
end
|
765
|
-
end
|
766
|
-
|
767
|
-
%w{6 16666 17}.each do |input|
|
768
|
-
it "should not match '#{input}'" do
|
769
|
-
subject.match(input).should == GRXML::NoMatch.new
|
770
|
-
end
|
771
|
-
end
|
772
|
-
end
|
773
|
-
|
774
|
-
context "with a grammar that takes a specific digit, followed by a specific digit repeated a minimum number of times" do
|
775
|
-
subject do
|
776
|
-
GRXML.draw :mode => :dtmf, :root => 'digits' do
|
777
|
-
rule :id => 'digits' do
|
778
|
-
string '1'
|
779
|
-
item :repeat => '2-' do
|
780
|
-
'6'
|
781
|
-
end
|
782
|
-
end
|
783
|
-
end
|
784
|
-
end
|
785
|
-
|
786
|
-
{
|
787
|
-
'166' => 'dtmf-1 dtmf-6 dtmf-6',
|
788
|
-
'1666' => 'dtmf-1 dtmf-6 dtmf-6 dtmf-6',
|
789
|
-
'16666' => 'dtmf-1 dtmf-6 dtmf-6 dtmf-6 dtmf-6'
|
790
|
-
}.each_pair do |input, interpretation|
|
791
|
-
it "should match '#{input}'" do
|
792
|
-
expected_match = GRXML::Match.new :mode => :dtmf,
|
793
|
-
:confidence => 1,
|
794
|
-
:utterance => input,
|
795
|
-
:interpretation => interpretation
|
796
|
-
subject.match(input).should == expected_match
|
797
|
-
end
|
798
|
-
end
|
799
|
-
|
800
|
-
%w{1 16}.each do |input|
|
801
|
-
it "should potentially match '#{input}'" do
|
802
|
-
subject.match(input).should == GRXML::PotentialMatch.new
|
803
|
-
end
|
804
|
-
end
|
805
|
-
|
806
|
-
%w{7 17}.each do |input|
|
807
|
-
it "should not match '#{input}'" do
|
808
|
-
subject.match(input).should == GRXML::NoMatch.new
|
809
|
-
end
|
810
|
-
end
|
811
|
-
end
|
812
|
-
|
813
|
-
context "with a grammar that takes a 4 digit pin terminated by hash, or the *9 escape sequence" do
|
814
|
-
subject do
|
815
|
-
RubySpeech::GRXML.draw :mode => :dtmf, :root => 'pin' do
|
816
|
-
rule :id => 'digit' do
|
817
|
-
one_of do
|
818
|
-
('0'..'9').map { |d| item { d } }
|
819
|
-
end
|
820
|
-
end
|
821
|
-
|
822
|
-
rule :id => 'pin', :scope => 'public' do
|
823
|
-
one_of do
|
824
|
-
item do
|
825
|
-
item :repeat => '4' do
|
826
|
-
ruleref :uri => '#digit'
|
827
|
-
end
|
828
|
-
"#"
|
829
|
-
end
|
830
|
-
item do
|
831
|
-
"\* 9"
|
832
|
-
end
|
833
|
-
end
|
834
|
-
end
|
835
|
-
end
|
836
|
-
end
|
837
|
-
|
838
|
-
{
|
839
|
-
'*9' => 'dtmf-star dtmf-9',
|
840
|
-
'1234#' => 'dtmf-1 dtmf-2 dtmf-3 dtmf-4 dtmf-pound',
|
841
|
-
'5678#' => 'dtmf-5 dtmf-6 dtmf-7 dtmf-8 dtmf-pound',
|
842
|
-
'1111#' => 'dtmf-1 dtmf-1 dtmf-1 dtmf-1 dtmf-pound'
|
843
|
-
}.each_pair do |input, interpretation|
|
844
|
-
it "should match '#{input}'" do
|
845
|
-
expected_match = GRXML::Match.new :mode => :dtmf,
|
846
|
-
:confidence => 1,
|
847
|
-
:utterance => input,
|
848
|
-
:interpretation => interpretation
|
849
|
-
subject.match(input).should == expected_match
|
850
|
-
end
|
851
|
-
end
|
852
|
-
|
853
|
-
%w{* 1 12 123 1234}.each do |input|
|
854
|
-
it "should potentially match '#{input}'" do
|
855
|
-
pending
|
856
|
-
subject.match(input).should == GRXML::PotentialMatch.new
|
857
|
-
end
|
858
|
-
end
|
859
|
-
|
860
|
-
%w{11111 #1111 *7}.each do |input|
|
861
|
-
it "should not match '#{input}'" do
|
862
|
-
subject.match(input).should == GRXML::NoMatch.new
|
863
|
-
end
|
864
|
-
end
|
865
|
-
end
|
866
|
-
end
|
867
339
|
end # Grammar
|
868
340
|
end # GRXML
|
869
341
|
end # RubySpeech
|